]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Fixes for some minor bugs clang-analyzer and cppcheck found
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index 2375d55368c40d0d52c5e194f70f39a1439622b2..defbd407ca6e153cf2b0594ed4156aeff8805048 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1357,9 +1357,6 @@ bool ir_block_create_store_op(ir_block *self, lex_ctx ctx, int op, ir_value *tar
         irerror(self->context, "unreachable statement (%s)", self->label);
         return false;
     }
-    in = ir_instr_new(ctx, self, op);
-    if (!in)
-        return false;
 
     if (target->store == store_value &&
         (op < INSTR_STOREP_F || op > INSTR_STOREP_FNC))
@@ -1370,9 +1367,14 @@ bool ir_block_create_store_op(ir_block *self, lex_ctx ctx, int op, ir_value *tar
         return false;
     }
 
+    in = ir_instr_new(ctx, self, op);
+    if (!in)
+        return false;
+
     if (!ir_instr_op(in, 0, target, true) ||
         !ir_instr_op(in, 1, what, false))
     {
+        ir_instr_delete(in);
         return false;
     }
     vec_push(self->instr, in);
@@ -1439,8 +1441,10 @@ bool ir_block_create_return(ir_block *self, lex_ctx ctx, ir_value *v)
     if (!in)
         return false;
 
-    if (v && !ir_instr_op(in, 0, v, false))
+    if (v && !ir_instr_op(in, 0, v, false)) {
+        ir_instr_delete(in);
         return false;
+    }
 
     vec_push(self->instr, in);
     return true;