]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virURIFormat: abort() on failure
authorPeter Krempa <pkrempa@redhat.com>
Tue, 23 Feb 2021 17:28:31 +0000 (18:28 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Mar 2021 08:50:19 +0000 (09:50 +0100)
If the argument of 'xmlSaveUri' is non-NULL the function returns NULL on
OOM failure only. Thus we can directly abort rather than try to do the
impossible recovery.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
src/util/viruri.c

index 0aafd49d6d9ec5d7dc0393a187080b67f586ebe5..1e8808ddc6d5da04812a884e335c43b332cfca31 100644 (file)
@@ -238,11 +238,9 @@ virURIFormat(virURIPtr uri)
     if (!xmluri.server && !xmluri.port)
         xmluri.port = -1;
 
-    ret = (char *)xmlSaveUri(&xmluri);
-    if (!ret) {
-        virReportOOMError();
-        return NULL;
-    }
+    /* xmlSaveUri can fail only on OOM condition if argument is non-NULL */
+    if (!(ret = (char *)xmlSaveUri(&xmluri)))
+        abort();
 
     return ret;
 }