virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic

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>
This commit is contained in:
Peter Krempa 2021-02-24 11:30:24 +01:00
parent 5591ba2889
commit d877eb1ddc
1 changed files with 2 additions and 6 deletions

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