[vlc-commits] Fix leak in error path

Petri Hintukainen git at videolan.org
Wed Nov 25 23:18:31 CET 2015


vlc | branch: master | Petri Hintukainen <phintuka at gmail.com> | Mon Nov 23 09:31:46 2015 +0200| [d9a8f8cd91064ca27c035094952983f2df510096] | committer: Jean-Baptiste Kempf

Fix leak in error path

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d9a8f8cd91064ca27c035094952983f2df510096
---

 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))



More information about the vlc-commits mailing list