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

Fixes #1258.
This commit is contained in:
Jeroen van Rijn
2021-11-01 10:42:57 +01:00
parent 0bc3652fc7
commit a422d0455e

View File

@@ -244,7 +244,12 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
operand->mode = Addressing_Value;
} else if (name == "load") {
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;
}
@@ -315,7 +320,11 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32
} else if (name == "load_or") {
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;
}