mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
esx: Fix managed object lookup with optional occurrence
Exit early if managed object is not found, instead of dereferencing a NULL pointer and triggering a segfault.
This commit is contained in:
parent
d1a366be05
commit
4d3d3e475f
@ -3964,7 +3964,7 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
|
|||||||
|
|
||||||
|
|
||||||
#define ESX_VI__TEMPLATE__LOOKUP(_type, _complete_properties, \
|
#define ESX_VI__TEMPLATE__LOOKUP(_type, _complete_properties, \
|
||||||
_cast_from_anytype) \
|
_cast_from_anytype) \
|
||||||
int \
|
int \
|
||||||
esxVI_Lookup##_type(esxVI_Context *ctx, const char* name /* optional */, \
|
esxVI_Lookup##_type(esxVI_Context *ctx, const char* name /* optional */, \
|
||||||
esxVI_ManagedObjectReference *root, \
|
esxVI_ManagedObjectReference *root, \
|
||||||
@ -3999,6 +3999,12 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio
|
|||||||
goto cleanup; \
|
goto cleanup; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
|
if (objectContent == NULL) { \
|
||||||
|
/* not found, exit early */ \
|
||||||
|
result = 0; \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
\
|
||||||
if (esxVI_##_type##_Alloc(ptrptr) < 0) { \
|
if (esxVI_##_type##_Alloc(ptrptr) < 0) { \
|
||||||
goto cleanup; \
|
goto cleanup; \
|
||||||
} \
|
} \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user