correct a memory leak
[calc.git] / parser.c
index 714ea87168fb069db17fb72c0393bbee9666a304..2e83a4f451f74a766e1b70e2b3c2f3567eafdf50 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -896,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);
 }
 
@@ -1209,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]);
             }