]> ocean-lang.org Git - ocean/blobdiff - csrc/parsergen.mdc
indent_test / parsergen: fix various memory leaks.
[ocean] / csrc / parsergen.mdc
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);
        }