compat/freebsd_network: Fix Use of zero-allocated memory
If device is not found, 'list' is allocated to size 0. So, modify function to return 0 as FreeBSD's subr_bus.c when 'count' is 0. Pointed out by Clang Static Analyzer. Change-Id: Ice24ae939bfcdb6e1276a86dba40d0b689030fbb Reviewed-on: https://review.haiku-os.org/c/haiku/+/3753 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
761714b3f6
commit
8cd3603b99
@ -198,6 +198,12 @@ device_get_children(device_t dev, device_t **devlistp, int *devcountp)
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
*devlistp = NULL;
|
||||||
|
*devcountp = 0;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
list = malloc(count * sizeof(device_t));
|
list = malloc(count * sizeof(device_t));
|
||||||
if (!list)
|
if (!list)
|
||||||
return (ENOMEM);
|
return (ENOMEM);
|
||||||
|
Loading…
Reference in New Issue
Block a user