[vlc-commits] commit: Fixed two potential segfaults in ToCharset(). (Laurent Aimar )

git at videolan.org git at videolan.org
Wed Nov 3 23:31:14 CET 2010


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Wed Nov  3 23:25:07 2010 +0100| [7fe74e0d5cec4d2eacf872991154597c4e79e330] | committer: Laurent Aimar 

Fixed two potential segfaults in ToCharset().

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

 src/text/unicode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/text/unicode.c b/src/text/unicode.c
index 5b40abc..1dd7985 100644
--- a/src/text/unicode.c
+++ b/src/text/unicode.c
@@ -435,7 +435,7 @@ void *ToCharset(const char *charset, const char *in, size_t *outsize)
 
         const char *inp = in;
         char *outp = res;
-        size_t inb = inlen + 1;
+        size_t inb = inlen;
         size_t outb = outlen;
 
         if (vlc_iconv (hd, &inp, &inb, &outp, &outb) != (size_t)(-1))
@@ -449,6 +449,7 @@ void *ToCharset(const char *charset, const char *in, size_t *outsize)
         }
 
         free (res);
+        res = NULL;
         if (errno != E2BIG) /* conversion failure */
         {
             res = NULL;



More information about the vlc-commits mailing list