Cast int to size_t before adding instead of casting the result.

Quiets PVS-Studio warning V1028.
This commit is contained in:
Todd C. Miller
2023-08-21 12:50:31 -06:00
parent 9f05bfd298
commit c6987aa26e
6 changed files with 9 additions and 8 deletions

View File

@@ -286,7 +286,8 @@ find_editor(int nfiles, char * const files[], char **argv_out[])
}
if (editor_path != editor)
free(editor);
nargv = reallocarray(NULL, (size_t)(nargc + 1 + nfiles + 1), sizeof(char *));
nargv = reallocarray(NULL, (size_t)nargc + 1 + (size_t)nfiles + 1,
sizeof(char *));
if (nargv == NULL) {
sudo_log(SUDO_CONV_ERROR_MSG, "unable to allocate memory\n");
free(editor_path);