Browse Source

Fixed a rare memory leak

Marco Bambini 1 year ago
parent
commit
fe1e2f5cb6
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/compiler/gravity_ircode.c

+ 4 - 1
src/compiler/gravity_ircode.c

@@ -43,7 +43,10 @@ ircode_t *ircode_create (uint16_t nlocals) {
     code->error = false;
 
     code->list = mem_alloc(NULL, sizeof(code_r));
-    if (!code->list) return NULL;
+    if (!code->list) {
+        mem_free(code);
+        return NULL;
+    }
     marray_init(*code->list);
     marray_init(code->label_true);
     marray_init(code->label_false);