]> xenbits.xensource.com Git - libvirt.git/commitdiff
esx_vi: fix possible segfault
authorPavel Hrdina <phrdina@redhat.com>
Wed, 21 Jan 2015 10:17:52 +0000 (11:17 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 22 Jan 2015 17:30:18 +0000 (18:30 +0100)
Clang found possible dereference of NULL pointer which is right.
Function 'esxVI_LookupTaskInfoByTask' should find a task info. The issue
is that we could return 0 and leave 'taksInfo' pointer NULL because if
there is no match we simply end the search loop end set 'result' to 0.
Every caller count on the fact that if the return value is 0 than it's
safe to dereference 'taskInfo'. We should return 0 only in case we found
something and the '*taskInfo' is not NULL.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/esx/esx_vi.c

index a87f2c09aae9e18a5d4df67b552032bdac8b5923..bbec912479dec1064af1f28b149c2b0183b73c6f 100644 (file)
@@ -3292,14 +3292,13 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx,
                 goto cleanup;
             }
 
+            result = 0;
             break;
         } else {
             VIR_WARN("Unexpected '%s' property", dynamicProperty->name);
         }
     }
 
-    result = 0;
-
  cleanup:
     esxVI_String_Free(&propertyNameList);
     esxVI_ObjectContent_Free(&objectContent);