[libvirt PATCH 2/2] testsutilsqemu: check return value of virQEMUCapsNewCopy

Ján Tomko posted 2 patches 5 years, 2 months ago
[libvirt PATCH 2/2] testsutilsqemu: check return value of virQEMUCapsNewCopy
Posted by Ján Tomko 5 years, 2 months ago
While for virQEMUCapsNew this should not be needed
(the possible failures in VIR_CLASS_NEW are only hit
 on bad API usage which we don't do here),
virQEMUCapsNewCopy calls into many other functions,
some of which actually fail.

Check the return value of both.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 tests/testutilsqemu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c
index 906fdf5c1a..cea4f84b14 100644
--- a/tests/testutilsqemu.c
+++ b/tests/testutilsqemu.c
@@ -349,6 +349,9 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache,
             tmpCaps = virQEMUCapsNew();
         }
 
+        if (!tmpCaps)
+            return -1;
+
         if (!virQEMUCapsHasMachines(tmpCaps)) {
             const char *defaultRAMid = NULL;
 
-- 
2.26.2

Re: [libvirt PATCH 2/2] testsutilsqemu: check return value of virQEMUCapsNewCopy
Posted by Peter Krempa 5 years, 2 months ago
On Fri, Nov 20, 2020 at 14:46:07 +0100, Ján Tomko wrote:
> While for virQEMUCapsNew this should not be needed
> (the possible failures in VIR_CLASS_NEW are only hit
>  on bad API usage which we don't do here),
> virQEMUCapsNewCopy calls into many other functions,
> some of which actually fail.
> 
> Check the return value of both.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>  tests/testutilsqemu.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>