Skip to content

Commit c75c626

Browse files
gh-82: Restrict GOTOPOINT to STR and positive INT.
1 parent 46214a6 commit c75c626

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/interpreter.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,14 @@ static ExecResult exec_stmt_list(Interpreter* interp, StmtList* list, Env* env,
31453145
if (interp->error) {
31463146
return make_error(interp->error, interp->error_line, interp->error_col);
31473147
}
3148+
if (!(target.type == VAL_INT || target.type == VAL_STR)) {
3149+
value_free(target);
3150+
return make_error("GOTOPOINT requires INT or STR argument", stmt->line, stmt->column);
3151+
}
3152+
if (target.type == VAL_INT && target.as.i < 0) {
3153+
value_free(target);
3154+
return make_error("Negative GOTOPOINT identifier is not allowed", stmt->line, stmt->column);
3155+
}
31483156
label_map_add(labels, target, (int)i);
31493157
value_free(target);
31503158
}

0 commit comments

Comments
 (0)