mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06: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:
committed by
Peter Krempa
parent
2cdbfbe7ac
commit
b62e51e540
@@ -156,6 +156,9 @@ static int printEnvironment(FILE *log)
|
||||
for (length = 0; environ[length]; length++) {
|
||||
}
|
||||
|
||||
if (length == 0)
|
||||
return 0;
|
||||
|
||||
if (!(newenv = malloc(sizeof(*newenv) * length)))
|
||||
return -1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user