From: Peter Krempa Date: Wed, 24 Feb 2021 10:30:24 +0000 (+0100) Subject: virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic X-Git-Tag: v7.2.0-rc1~269 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d877eb1ddcfe6204b80937e019531f501c6c57e7;p=thirdparty%2Flibvirt.git 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 Reviewed-by: Laine Stump --- diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index e6c0900a65..73bf7c4f3d 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -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;