cppcheck: fix null ptr dereference

This commit is contained in:
Philippe Teuwen
2026-02-06 15:55:14 +01:00
parent 3234c2ba47
commit 26c8b502e2
+9
View File
@@ -163,6 +163,10 @@ static int split(char *str, char **arr) {
int len = end_index - begin_index;
char *tmp = calloc(len + 1, sizeof(char));
if (tmp == NULL) {
PrintAndLogEx(ERR, "Memory allocation failed");
return -1;
}
memcpy(tmp, &str[begin_index], len);
arr[word_cnt++] = tmp;
begin_index = end_index;
@@ -457,6 +461,11 @@ static int CmdScriptRun(const char *Cmd) {
char *argv[FILE_PATH_SIZE];
argv[0] = script_path;
int argc = split(arguments, &argv[1]);
if (argc < 0) {
PrintAndLogEx(ERR, "Failed to parse script arguments");
free(script_path);
return PM3_ESOFT;
}
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 10
wchar_t *py_args[argc + 1];
for (int i = 0; i <= argc; i++) {