incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Travis Vitek <vi...@roguewave.com>
Subject [PATCH] rw_snprintf doesn't null terminate strings
Date Tue, 18 Dec 2007 22:52:58 GMT


If rw_snprintf() is intended to behave like sprintf(), it should probably
append the null terminator. If not, I should probably revise my fix to
STDCXX-524 [https://issues.apache.org/jira/browse/STDCXX-524].

Travis 


Index: printf.cpp
===================================================================
--- printf.cpp	(revision 605328)
+++ printf.cpp	(working copy)
@@ -3376,8 +3376,10 @@
 
     va_end (va);
 
-    if (size_t (nchars) <= bufsize)
+    if (size_t (nchars) < bufsize) {
         memcpy (buf, tmpbuf, size_t (nchars));
+        buf [nchars] = 0;
+    }
 
     free (tmpbuf);
-- 
View this message in context: http://www.nabble.com/-PATCH--rw_snprintf-doesn%27t-null-terminate-strings-tp14407607p14407607.html
Sent from the stdcxx-dev mailing list archive at Nabble.com.


Mime
View raw message