]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ast.c
Update doc/specification.tex
[xonotic/gmqcc.git] / ast.c
diff --git a/ast.c b/ast.c
index 3a4f1d7b2782f39983174d686a889a9f1e497dae..294c13b42dc175f369db95f6101868041b43a670 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -660,8 +660,10 @@ ast_array_index* ast_array_index_new(lex_ctx ctx, ast_expression *array, ast_exp
 
 void ast_array_index_delete(ast_array_index *self)
 {
-    ast_unref(self->array);
-    ast_unref(self->index);
+    if (self->array)
+        ast_unref(self->array);
+    if (self->index)
+        ast_unref(self->index);
     ast_expression_delete((ast_expression*)self);
     mem_d(self);
 }
@@ -2834,7 +2836,7 @@ bool ast_switch_codegen(ast_switch *self, ast_function *func, bool lvalue, ir_va
         return true;
 
     cmpinstr = type_eq_instr[irop->vtype];
-    if (cmpinstr >= AINSTR_END) {
+    if (cmpinstr >= VINSTR_END) {
         ast_type_to_string(self->operand, typestr, sizeof(typestr));
         compile_error(ast_ctx(self), "invalid type to perform a switch on: %s", typestr);
         return false;