[vlc-devel] [PATCH] Fix leak in error path

Petri Hintukainen phintuka at gmail.com
Mon Nov 23 08:31:46 CET 2015


---
 include/vlc_charset.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/vlc_charset.h b/include/vlc_charset.h
index 4de57ab..3119e89 100644
--- a/include/vlc_charset.h
+++ b/include/vlc_charset.h
@@ -85,8 +85,10 @@ static inline char *ToCodePage (unsigned cp, const char *utf8)
         return NULL;
 
     size_t len = WideCharToMultiByte (cp, 0, wide, -1, NULL, 0, NULL, NULL);
-    if (len == 0)
+    if (len == 0) {
+        free(wide);
         return NULL;
+    }
 
     char *out = (char *)malloc (len);
     if (likely(out != NULL))
-- 
2.5.0



More information about the vlc-devel mailing list