Fix: ctf: free all scopes of ctf_scanner
[babeltrace.git] / src / plugins / ctf / common / metadata / parser.y
index bada61d74bfdae66348517fdb85b6eee740187a7..a75cff056afc4233a5473bffbb23d596db537f9b 100644 (file)
@@ -1001,7 +1001,24 @@ void ctf_scanner_free(struct ctf_scanner *scanner)
 
        if (!scanner)
                return;
-       finalize_scope(&scanner->root_scope);
+
+       struct ctf_scanner_scope *scope = scanner->cs;
+
+       do {
+               struct ctf_scanner_scope *parent = scope->parent;
+               finalize_scope(scope);
+
+               /*
+                * The root scope is allocated within the ctf_scanner structure,
+                * do doesn't need freeing.  All others are allocated on their
+                * own.
+                */
+               if (scope != &scanner->root_scope)
+                       free(scope);
+
+               scope = parent;
+       } while (scope);
+
        objstack_destroy(scanner->objstack);
        ret = yylex_destroy(scanner->scanner);
        if (ret)
This page took 0.023312 seconds and 4 git commands to generate.