X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=parser.c;h=2e83a4f451f74a766e1b70e2b3c2f3567eafdf50;hb=3d3e6770191a1eb48cf66898397a1a6e31b7cb89;hp=3d8681cdf3bb7f6d8972459744b15f2b64486928;hpb=779282bba9b01f32ff208220e35cfc266721bacc;p=calc.git diff --git a/parser.c b/parser.c index 3d8681c..2e83a4f 100644 --- a/parser.c +++ b/parser.c @@ -480,7 +480,9 @@ element_t *parser (char *str, char **next, int prio) } /* save string */ - root->string = string; + if (root != NULL) { + root->string = string; + } return root; } @@ -780,6 +782,7 @@ void prog (int id, int nbmems, element_t *root) } if ((programs + n)->string) { free ((programs + n)->string); + (programs + n)->string = NULL; } } } @@ -893,15 +896,16 @@ void savestring (int id, char *string) } } } - if (n == -1) { - VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id)); - return; - } - /* save program */ - if ((programs + n)->string) { - free ((programs + n)->string); - } + /* unnecesary code */ + //if (n == -1) { + // VERBOSE (WARNING, fprintf (stdout, "error unknown program (%d)\n", id)); + // return; + //} + //if ((programs + n)->string) { + // free ((programs + n)->string); + //} + (programs + n)->string = strdup (string); } @@ -1206,7 +1210,7 @@ void free_completion_list (char **list) int i; if (list) { - for (i = 0; i < NB_FUNCTIONS + NB_CONSTANTS; i++) { + for (i = 0; i < NB_OPERATORS + NB_FUNCTIONS + NB_CONSTANTS + NB_SYMBOLS + 1; i++) { if (list[i] != NULL) { free (list[i]); }