]> ocean-lang.org Git - ocean/commitdiff
indent_test / parsergen: fix various memory leaks.
authorNeilBrown <neilb@suse.de>
Sun, 11 May 2014 07:18:21 +0000 (17:18 +1000)
committerNeilBrown <neilb@suse.de>
Sun, 15 Jun 2014 07:20:06 +0000 (17:20 +1000)
thanks valgrind...

Signed-off-by: NeilBrown <neilb@suse.de>
csrc/indent_test.cgm
csrc/parsergen.mdc

index 50fc4a5f7ea69a3601a051e580992b84c79a53d3..ac3ab55fe49d25b5ffa31778fe87d5c5fe6b444e 100644 (file)
@@ -45,6 +45,7 @@ with complete bracketing and indenting.
                if (!s)
                        return;
                free_statement(s->next);
+               free_expression(s->expr);
                free_statement(s->thenpart);
                free_statement(s->elsepart);
                free(s);
@@ -97,6 +98,12 @@ with complete bracketing and indenting.
                        .word_cont = "",
                };
                parse_itest(s->code, &config, argc > 2 ? stderr : NULL);
+               while (s) {
+                       struct section *t = s->next;
+                       code_free(s->code);
+                       free(s);
+                       s = t;
+               }
                exit(0);
        }
 
index b3d1cf638b3d47a4ff84add7b05c89eef59d86de..0f1dd2693cc4f360132ced75bf380214c169230b 100644 (file)
@@ -2103,11 +2103,12 @@ appropriate for tokens on any terminal symbol.
                                continue;
 
                        fprintf(f, "\tcase %d:\n", s->num);
-                       if (s->isref)
+                       if (s->isref) {
                                fprintf(f, "\t\tfree_%.*s(*(void**)asn);\n",
                                        s->struct_name.len,
                                        s->struct_name.txt);
-                       else
+                               fprintf(f, "\t\tfree(asn);\n");
+                       } else
                                fprintf(f, "\t\tfree_%.*s(asn);\n",
                                        s->struct_name.len,
                                        s->struct_name.txt);
@@ -2839,6 +2840,12 @@ an error.
                        .word_cont = "",
                };
                parse_calc(s->code, &config, argc > 2 ? stderr : NULL);
+               while (s) {
+                       struct section *t = s->next;
+                       code_free(s->code);
+                       free(s);
+                       s = t;
+               }
                exit(0);
        }