From: Matthias Bolte Date: Tue, 6 Sep 2011 17:05:08 +0000 (+0200) Subject: esx: Fix managed object lookup with optional occurrence X-Git-Tag: v0.9.5-rc2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d3d3e475f96935b7cf9fce2a28d3b2563502848;p=thirdparty%2Flibvirt.git 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. --- diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index 5c8d79e56c..f4033eb8e0 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -3964,7 +3964,7 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio #define ESX_VI__TEMPLATE__LOOKUP(_type, _complete_properties, \ - _cast_from_anytype) \ + _cast_from_anytype) \ int \ esxVI_Lookup##_type(esxVI_Context *ctx, const char* name /* optional */, \ esxVI_ManagedObjectReference *root, \ @@ -3999,6 +3999,12 @@ esxVI_ProductVersionToDefaultVirtualHWVersion(esxVI_ProductVersion productVersio goto cleanup; \ } \ \ + if (objectContent == NULL) { \ + /* not found, exit early */ \ + result = 0; \ + goto cleanup; \ + } \ + \ if (esxVI_##_type##_Alloc(ptrptr) < 0) { \ goto cleanup; \ } \