|
From: <sv...@va...> - 2013-02-26 21:55:16
|
philippe 2013-02-26 21:54:28 +0000 (Tue, 26 Feb 2013)
New Revision: 13291
Log:
Fix vassert_fail producing random output for an empty format
vsnprintf does not do any addition to the buffer for an empty
format. So, buf was not null terminated.
This e.g. causes an assert_fail to output random characters
after the failed expression.
Fix by ensuring the buffer of vsnprintf is always null terminated
to start with.
Modified files:
trunk/coregrind/m_libcprint.c
Modified: trunk/coregrind/m_libcprint.c (+2 -1)
===================================================================
--- trunk/coregrind/m_libcprint.c 2013-02-24 23:16:58 +00:00 (rev 13290)
+++ trunk/coregrind/m_libcprint.c 2013-02-26 21:54:28 +00:00 (rev 13291)
@@ -232,7 +232,8 @@
b.buf = buf;
b.buf_size = size < 0 ? 0 : size;
b.buf_used = 0;
-
+ if (b.buf_size > 0)
+ b.buf[0] = 0; // ensure to null terminate buf if empty format
(void) VG_(debugLog_vprintf)
( add_to__snprintf_buf, &b, format, vargs );
|