[vlc-devel] [PATCH] WinCE: fix infinite loop in vasprintf replacement

Pierre Ynard linkfanel at yahoo.fr
Thu Feb 19 17:04:02 CET 2009


WinCE's vsnprintf does return the number of characters to write, instead
of -1, if it is equal to the size argument, whereas in this case the
output was indeed truncated (the final '\0' was truncated). Failure to
handle this case leads to infinite loops, when the number of characters
to write equals exactly 50 (which happens for example when trying to
play an mp4 file).


diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index 726bb9e..87626e8 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -77,8 +77,7 @@ static inline int vasprintf (char **strp, const char *fmt, va_list ap)
         }
 
         /* Else try again with more space. */
-        if (n == -1)
-            size *= 2;  /* twice the old size */
+        size *= 2;  /* twice the old size */
 
         if ((np = (char *) realloc (res, size)) == NULL)
         {


Regards,

-- 
Pierre Ynard
"Une âme dans un corps, c'est comme un dessin sur une feuille de papier."



More information about the vlc-devel mailing list