[vlc-commits] commit: snprintf() always puts a nul terminator... ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Sun Apr 11 10:22:01 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 11 11:19:42 2010 +0300| [a54335c703c1abb1ea72a109bd99a6919f57ce70] | committer: Rémi Denis-Courmont 

snprintf() always puts a nul terminator...

...unless the buffer has zero size.
This is not to be confused with strncpy().

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

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

diff --git a/src/libvlc.c b/src/libvlc.c
index b5c8733..b11f40f 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -1177,8 +1177,7 @@ static void SetLanguage ( const char *psz_lang )
      * makes the environment unconsistent when libvlc is unloaded and
      * should probably be moved to a safer place like vlc.c. */
     static char psz_lcall[20];
-    snprintf( psz_lcall, 19, "LC_ALL=%s", psz_lang );
-    psz_lcall[19] = '\0';
+    snprintf( psz_lcall, sizeof(psz_lcall), "LC_ALL=%s", psz_lang );
     putenv( psz_lcall );
 #endif
 



More information about the vlc-commits mailing list