aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2021-11-01 10:42:57 +0100
committerJeroen van Rijn <Kelimion@users.noreply.github.com>2021-11-01 10:42:57 +0100
commita422d0455e89195b2e177b553fe69a59020e84ab (patch)
tree1d6a57863ed6caa7b6372e6fc786ef85e79a7be4 /src
parent0bc3652fc7ef2d06c17043220275932875658e10 (diff)
Fix (#1258): #load and #load_or segfault when given no params.
Fixes #1258.
Diffstat (limited to 'src')
-rw-r--r--src/check_builtin.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 482813792..e405343b9 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -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;
}