2nd attempt to fix a linter error for step 49 of "Path"

This commit is contained in:
Hinko Kocevar
2025-04-06 12:49:08 +02:00
committed by Andrew Johnson
parent de6d4e74ef
commit e294bb443c

View File

@@ -852,12 +852,13 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf,
case iocshArgPersistentString:
if (arg != NULL) {
argBuf->sval = (char *) malloc(strlen(arg) + 1);
size_t slen = strlen(arg);
argBuf->sval = (char *) malloc(slen + 1);
if (argBuf->sval == NULL) {
showError(filename, lineno, ANSI_RED("Out of memory!"));
return 0;
}
strcpy(argBuf->sval, arg);
strncpy(argBuf->sval, arg, slen);
} else {
argBuf->sval = NULL;
}