mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
05708d7985
commit
d7b100f932
1 changed files with 3 additions and 3 deletions
|
|
@ -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 a new issue