From 0c52d44d3ec74387f566f34c7a4d7aa27c00cf2f Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Sat, 30 Dec 2023 11:45:23 +0900 Subject: [PATCH] names array is not NULL-terminated; use 'oarg' which should be count of names at this point --- src/parseargs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parseargs.c b/src/parseargs.c index 281aa466..9e69c0bd 100644 --- a/src/parseargs.c +++ b/src/parseargs.c @@ -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; } }