mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-08 10:06:32 +00:00
nvfile: Free allocated memory on failure
In TPM_NVRAM_LoadData(), there is an unlikely path where the function will return an error code but still expect the caller to free the allocated data. At least some of the callers don't handle this correctly so ensure that the caller only needs to free data if the function returns success. Reported by Coverity. Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
This commit is contained in:
parent
f9a6f51cb8
commit
71d3a27bc7
@ -267,6 +267,11 @@ TPM_RESULT TPM_NVRAM_LoadData(unsigned char **data, /* freed by caller */
|
||||
printf(" TPM_NVRAM_LoadData: Closed file %s\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
free(*data);
|
||||
*data = NULL;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user