On 2/24/21 11:17 AM, Peter Krempa wrote:
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(a)redhat.com>
---
src/vmx/vmx.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
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) {
I would have left the error messages for the two functions separate,
with adequate wording to tell which of them failed. But this is at worst
still better than reporting OOM...
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Could not convert from %s to UTF-8 encoding"),
encoding);
goto cleanup;