[Libguestfs] [PATCH 1/2] Fix garbage return value on error

Peter Wu peter at lekensteyn.nl
Thu Aug 7 15:59:49 UTC 2014


If str contains invalid characters, ret is not initialised. Caught by
Clang static analyzer.
---
 lib/utf16.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/utf16.c b/lib/utf16.c
index f4299f2..7d275fd 100644
--- a/lib/utf16.c
+++ b/lib/utf16.c
@@ -128,7 +128,7 @@ size_t
 _hivex_utf8_strlen (const char* str, size_t len, int utf16)
 {
   const char *encoding = utf16 ? "UTF-16LE" : "LATIN1";
-  size_t ret;
+  size_t ret = 0;
   char *buf = _hivex_recode(encoding, str, len, "UTF-8", &ret);
   free(buf);
   return ret;
-- 
2.0.2




More information about the Libguestfs mailing list