1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-25 01:34:11 +03:00

vbox: abort() on allocation failure in UTF8<->UTF16 conversion

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>
This commit is contained in:
Peter Krempa 2021-02-24 10:20:55 +01:00
parent 695d469238
commit 3fdf0013e5
2 changed files with 13 additions and 22 deletions

View 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);

View 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))