mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
conf: avoid null deref during storage probe
Commit 5c43e2e introduced a NULL deref if there is a failure in virStorageFileGetMetadataInternal. * src/util/virstoragefile.c (virStorageFileGetMetadataFromBuf): Fix error handling. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
0e285a588a
commit
c9679edca9
@ -999,21 +999,21 @@ virStorageFileGetMetadataFromBuf(const char *path,
|
||||
int *backingFormat)
|
||||
{
|
||||
virStorageSourcePtr ret = NULL;
|
||||
virStorageSourcePtr meta = NULL;
|
||||
|
||||
if (!(ret = virStorageFileMetadataNew(path, format)))
|
||||
if (!(meta = virStorageFileMetadataNew(path, format)))
|
||||
return NULL;
|
||||
|
||||
if (virStorageFileGetMetadataInternal(ret, buf, len,
|
||||
backingFormat) < 0) {
|
||||
virStorageSourceFree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
|
||||
if (VIR_STRDUP(*backing, ret->backingStoreRaw) < 0) {
|
||||
virStorageSourceFree(ret);
|
||||
ret = NULL;
|
||||
}
|
||||
if (virStorageFileGetMetadataInternal(meta, buf, len,
|
||||
backingFormat) < 0)
|
||||
goto cleanup;
|
||||
if (VIR_STRDUP(*backing, meta->backingStoreRaw) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = meta;
|
||||
meta = NULL;
|
||||
cleanup:
|
||||
virStorageSourceFree(meta);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user