2nd attempt to fix a linter error for step 49 of "Path"
This commit is contained in:
committed by
Andrew Johnson
parent
de6d4e74ef
commit
e294bb443c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user