]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vbox: Fix passing an empty IMedium* array to IMachine::Delete
authorMatthias Bolte <matthias.bolte@googlemail.com>
Sun, 22 Apr 2012 08:31:33 +0000 (10:31 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Mon, 23 Apr 2012 19:44:51 +0000 (21:44 +0200)
vboxArray is not castable to a COM item type. vboxArray is a
wrapper around the XPCOM and MSCOM specific array handling.

In this case we can avoid passing NULL as an empty array to
IMachine::Delete by passing a dummy IMedium* array with a single
NULL item.

src/vbox/vbox_tmpl.c

index 57c18a432ec716b1d0ea2059c575f6a6ac6963c9..4b0ee2efce99eb5698b029f95367d9437d4e3d2e 100644 (file)
@@ -5294,11 +5294,10 @@ vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags)
 
         ((IMachine_Delete)machine->vtbl->Delete)(machine, &safeArray, &progress);
 # else
-        union {
-            vboxArray array;
-            IMedium *medium;
-        } u = { .array = VBOX_ARRAY_INITIALIZER };
-        machine->vtbl->Delete(machine, 0, &u.medium, &progress);
+        /* XPCOM doesn't like NULL as an array, even when the array size is 0.
+         * Instead pass it a dummy array to avoid passing NULL. */
+        IMedium *array[] = { NULL };
+        machine->vtbl->Delete(machine, 0, array, &progress);
 # endif
         if (progress != NULL) {
             progress->vtbl->WaitForCompletion(progress, -1);