Skip to content

Commit

Permalink
[CLI]:program crashes after second command
Browse files Browse the repository at this point in the history
  • Loading branch information
Nowres RAFID committed Sep 29, 2011
1 parent 279ba5f commit f666fb7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions tests/polynomes-cli/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,17 @@ struct {
/** BEGIN parameters manipulation helpers **/
char *pbuf;

static char* _helper_get_first_param (const char *params_l)
static void _helper_end_get_params ()
{
if (pbuf)
if (pbuf){
free (pbuf);
pbuf = NULL;
}
}

static char* _helper_get_first_param (const char *params_l)
{
_helper_end_get_params ();
pbuf = malloc( sizeof(*params_l) * (strlen(params_l) + 1) );
strcpy (pbuf , params_l);
return strtok (pbuf, " ");
Expand All @@ -33,10 +40,6 @@ static char* _helper_get_next_param ()
return strtok (NULL, " ");
}

static void _helper_end_get_params ()
{
if (pbuf) free (pbuf);
}
/** END parameters manipulation helpers **/


Expand Down

0 comments on commit f666fb7

Please sign in to comment.