]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Feb 2021 10:30:24 +0000 (11:30 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Mar 2021 08:50:20 +0000 (09:50 +0100)
The function has also non-OOM failure case when the passed string has 0
length, so reporting OOM error is not correct.

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

index e6c0900a6517f94a47918023998969a27c51563b..73bf7c4f3d62b73475ba8a92c76db290c6621c15 100644 (file)
@@ -781,12 +781,8 @@ virVMXConvertToUTF8(const char *encoding, const char *string)
         return NULL;
     }
 
-    if (!(input = xmlBufferCreateStatic((char *)string, strlen(string)))) {
-        virReportOOMError();
-        goto cleanup;
-    }
-
-    if (xmlCharEncInFunc(handler, utf8, input) < 0) {
+    if (!(input = xmlBufferCreateStatic((char *)string, strlen(string))) ||
+        xmlCharEncInFunc(handler, utf8, input) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Could not convert from %s to UTF-8 encoding"), encoding);
         goto cleanup;