mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
tests: Prevent malloc with size 0
Found by clang-tidy's "clang-analyzer-optin.portability.UnixAPI" check. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
2cdbfbe7ac
commit
b62e51e540
@ -156,6 +156,9 @@ static int printEnvironment(FILE *log)
|
|||||||
for (length = 0; environ[length]; length++) {
|
for (length = 0; environ[length]; length++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (length == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (!(newenv = malloc(sizeof(*newenv) * length)))
|
if (!(newenv = malloc(sizeof(*newenv) * length)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user