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:
Tim Wiederhake 2021-02-01 13:42:05 +01:00 committed by Peter Krempa
parent 2cdbfbe7ac
commit b62e51e540

View File

@ -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;