kvm_malloc:
When malloc fails. don't try to memset NULL pointer, it cause core dump Replace malloc+memset with calloc, theoretically it can do some optimization of zeroing process internally Improve error diagnostic
This commit is contained in:
parent
3f0c80b2e9
commit
26976c4aee
@ -155,9 +155,9 @@ _kvm_malloc(kd, n)
|
||||
{
|
||||
void *p;
|
||||
|
||||
if ((p = malloc(n)) == NULL)
|
||||
_kvm_err(kd, kd->program, strerror(errno));
|
||||
memset(p, 0, n);
|
||||
if ((p = calloc(n, sizeof(char))) == NULL)
|
||||
_kvm_err(kd, kd->program, "can't allocate %u bytes: %s",
|
||||
n, strerror(errno));
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user