Re: [PATCH 32/33] virVMXConvertToUTF8: Report non-OOM error on failure of xmlBufferCreateStatic

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
  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;





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux