Skip to content

Commit

Permalink
names array is not NULL-terminated; use 'oarg' which should be count …
Browse files Browse the repository at this point in the history
…of names at this point
  • Loading branch information
klange committed Dec 30, 2023
1 parent c7caf52 commit 0c52d44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/parseargs.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,10 @@ int krk_parseVArgs(
KrkTableEntry * entry = &AS_DICT(argv[argc])->entries[i];
if (IS_STRING(entry->key)) {
/* See if this was the name of an argument, which means it was already provided as a positional argument. */
for (const char ** name = names; *name; ++name) {
if (**name && !strcmp(*name, AS_CSTRING(entry->key))) {
for (int j = 0; j < oarg; ++j) {
if (*names[j] && strlen(names[j]) == AS_STRING(entry->key)->length && !strcmp(names[j], AS_CSTRING(entry->key))) {
krk_runtimeError(vm.exceptions->typeError, "%s() got multiple values for argument '%s'",
_method_name, *name);
_method_name, names[j]);
return 0;
}
}
Expand Down

0 comments on commit 0c52d44

Please sign in to comment.