Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Now handles readline() returning NULL correctly (user hits CTRL-D, etc).
  • Loading branch information
icculus committed Oct 23, 2002
1 parent 2143071 commit 41d1d28
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions test/test_physfs.c
Expand Up @@ -714,10 +714,17 @@ static void trim_command(const char *orig, char *copy)
static int process_command(char *complete_cmd)
{
const command_info *i;
char *cmd_copy = malloc(strlen(complete_cmd) + 1);
char *cmd_copy;
char *args;
int rc = 1;

if (complete_cmd == NULL) /* can happen if user hits CTRL-D, etc. */
{
printf("\n");
return(0);
} /* if */

cmd_copy = malloc(strlen(complete_cmd) + 1);
if (cmd_copy == NULL)
{
printf("\n\n\nOUT OF MEMORY!\n\n\n");
Expand Down Expand Up @@ -877,7 +884,8 @@ int main(int argc, char **argv)
#endif

rc = process_command(buf);
free(buf);
if (buf != NULL)
free(buf);
} while (rc);

if (!PHYSFS_deinit())
Expand Down

0 comments on commit 41d1d28

Please sign in to comment.