Browse Source

Fix (#1258): #load and #load_or segfault when given no params.

Fixes #1258.
Jeroen van Rijn 3 years ago
parent
commit
a422d0455e
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/check_builtin.cpp

+ 11 - 2
src/check_builtin.cpp

@@ -244,7 +244,12 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
 			operand->mode = Addressing_Value;
 			operand->mode = Addressing_Value;
 		} else if (name == "load") {
 		} else if (name == "load") {
 			if (ce->args.count != 1) {
 			if (ce->args.count != 1) {
-				error(ce->args[0], "'#load' expects 1 argument, got %td", ce->args.count);
+				if (ce->args.count == 0) {
+					error(ce->close, "'#load' expects 1 argument, got 0");
+				} else {
+					error(ce->args[0], "'#load' expects 1 argument, got %td", ce->args.count);					
+				}
+
 				return false;
 				return false;
 			}
 			}
 
 
@@ -315,7 +320,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
 
 
 		} else if (name == "load_or") {
 		} else if (name == "load_or") {
 			if (ce->args.count != 2) {
 			if (ce->args.count != 2) {
-				error(ce->args[0], "'#load_or' expects 2 arguments, got %td", ce->args.count);
+				if (ce->args.count == 0) {
+					error(ce->close, "'#load_or' expects 2 arguments, got 0");
+				} else {
+					error(ce->args[0], "'#load_or' expects 2 arguments, got %td", ce->args.count);
+				}
 				return false;
 				return false;
 			}
 			}