Fix: memleak on error path
[babeltrace.git] / formats / ctf / metadata / ctf-visitor-generate-io-struct.c
index a18f762c9b189b53aee0e58035e192499ea29957..fe0b6b4d9ed8db460cc9d5152d5e9a16805130a8 100644 (file)
@@ -1158,12 +1158,16 @@ struct bt_declaration *ctf_declaration_type_specifier_visit(FILE *fd, int depth,
 
        str = g_string_new("");
        ret = visit_type_specifier_list(fd, type_specifier_list, str);
-       if (ret)
+       if (ret) {
+               (void) g_string_free(str, TRUE);
                return NULL;
+       }
        str_c = g_string_free(str, FALSE);
        id_q = g_quark_from_string(str_c);
        g_free(str_c);
        declaration = bt_lookup_declaration(id_q, declaration_scope);
+       if (!declaration)
+               return NULL;
        bt_declaration_ref(declaration);
        return declaration;
 }
This page took 0.022904 seconds and 4 git commands to generate.