]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vbox: abort() on allocation failure in UTF8<->UTF16 conversion
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Feb 2021 09:20:55 +0000 (10:20 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Mar 2021 08:50:20 +0000 (09:50 +0100)
Trying to report an error on OOM is pointless since error handling
allocates memory.

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

index 0c4126bd38056cf97eb7b4bd01118d9f10fce474..69b99317f212d43655f5f4532ecdf52a13c9b2b3 100644 (file)
@@ -5465,17 +5465,9 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom,
     }
 
     VBOX_UTF8_TO_UTF16(def->parent.name, &name);
-    if (!name) {
-        virReportOOMError();
-        goto cleanup;
-    }
 
     if (def->parent.description) {
         VBOX_UTF8_TO_UTF16(def->parent.description, &description);
-        if (!description) {
-            virReportOOMError();
-            goto cleanup;
-        }
     }
 
     rc = gVBoxAPI.UIConsole.TakeSnapshot(console, name, description, &progress);
@@ -6475,10 +6467,6 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot,
         goto cleanup;
     }
     VBOX_UTF16_TO_UTF8(nameUtf16, &name);
-    if (!name) {
-        virReportOOMError();
-        goto cleanup;
-    }
 
     ret = virGetDomainSnapshot(dom, name);
 
@@ -6533,10 +6521,6 @@ vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags)
     }
 
     VBOX_UTF16_TO_UTF8(nameUtf16, &name);
-    if (!name) {
-        virReportOOMError();
-        goto cleanup;
-    }
 
     ret = virGetDomainSnapshot(dom, name);
 
@@ -6593,10 +6577,6 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot,
     }
 
     VBOX_UTF16_TO_UTF8(nameUtf16, &name);
-    if (!name) {
-        virReportOOMError();
-        goto cleanup;
-    }
 
     ret = STREQ(snapshot->name, name);
 
index 8b1fb2ac30a87901708b27d9f552b3270bc52950..1fb922aaf0ca710b0afe625a6d94cae04ffba1c8 100644 (file)
@@ -391,8 +391,19 @@ typedef nsISupports IKeyboard;
         } \
     } while (0)
 
-#define VBOX_UTF16_TO_UTF8(arg1, arg2)  gVBoxAPI.UPFN.Utf16ToUtf8(data->pFuncs, arg1, arg2)
-#define VBOX_UTF8_TO_UTF16(arg1, arg2)  gVBoxAPI.UPFN.Utf8ToUtf16(data->pFuncs, arg1, arg2)
+#define VBOX_UTF16_TO_UTF8(arg1, arg2) \
+    do { \
+        gVBoxAPI.UPFN.Utf16ToUtf8(data->pFuncs, arg1, arg2); \
+        if (!*(arg2)) \
+            abort(); \
+    } while (0)
+
+#define VBOX_UTF8_TO_UTF16(arg1, arg2) \
+    do { \
+        gVBoxAPI.UPFN.Utf8ToUtf16(data->pFuncs, arg1, arg2); \
+        if (!*(arg2)) \
+            abort(); \
+    } while (0)
 
 #define VBOX_ADDREF(arg)                gVBoxAPI.nsUISupports.AddRef((void *)(arg))