sudo_mmap_strdup_v1: Fix potential NULL pointer deref
This commit is contained in:
@@ -116,8 +116,10 @@ sudo_mmap_strdup_v1(const char *str)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
newstr = sudo_mmap_alloc_v1(len + 1);
|
newstr = sudo_mmap_alloc_v1(len + 1);
|
||||||
|
if (newstr != NULL) {
|
||||||
memcpy(newstr, str, len);
|
memcpy(newstr, str, len);
|
||||||
newstr[len] = '\0';
|
newstr[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
return newstr;
|
return newstr;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user