sudo_mmap_strdup_v1: Fix potential NULL pointer deref

This commit is contained in:
modric
2022-11-19 11:22:14 +08:00
parent 9c694e9a65
commit 1eabf13577

View File

@@ -116,8 +116,10 @@ sudo_mmap_strdup_v1(const char *str)
return NULL;
}
newstr = sudo_mmap_alloc_v1(len + 1);
memcpy(newstr, str, len);
newstr[len] = '\0';
if (newstr != NULL) {
memcpy(newstr, str, len);
newstr[len] = '\0';
}
return newstr;
}