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 <phrd...@redhat.com>
---
 src/esx/esx_vi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index a87f2c0..752d32a 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -3298,7 +3298,8 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx,
         }
     }
 
-    result = 0;
+    if (*taskInfo)
+        result = 0;
 
  cleanup:
     esxVI_String_Free(&propertyNameList);
-- 
2.0.5

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to