summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-03-13 20:19:04 (GMT)
committerJason Evans <je@fb.com>2012-03-13 20:19:04 (GMT)
commit824d34e5b7f5cf00bf472ec79f7ec1c6e3474114 (patch)
tree83267d784bf524ccdf8786088cd378e02f3517ed /src
parent0a0bbf63e5d9bc60d6854c6d46b437fbeebd1470 (diff)
downloadjemalloc-824d34e5b7f5cf00bf472ec79f7ec1c6e3474114.zip
jemalloc-824d34e5b7f5cf00bf472ec79f7ec1c6e3474114.tar.gz
jemalloc-824d34e5b7f5cf00bf472ec79f7ec1c6e3474114.tar.bz2
Modify malloc_vsnprintf() validation code.
Modify malloc_vsnprintf() validation code to verify that output is identical to vsnprintf() output, even if both outputs are truncated due to buffer exhaustion.
Diffstat (limited to 'src')
-rw-r--r--src/util.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/util.c b/src/util.c
index 7d658aa..47e7b66 100644
--- a/src/util.c
+++ b/src/util.c
@@ -433,7 +433,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
ret = i;
if (config_debug) {
- char buf[ret + 2];
+ char buf[MALLOC_PRINTF_BUFSIZE];
int tret;
/*
@@ -442,7 +442,7 @@ malloc_vsnprintf(char *str, size_t size, const char *format, va_list ap)
*/
tret = vsnprintf(buf, sizeof(buf), format, tap);
assert(tret == ret);
- assert(memcmp(str, buf, ret + 1) == 0);
+ assert(strcmp(buf, str) == 0);
}
#undef APPEND_C
@@ -469,8 +469,7 @@ malloc_snprintf(char *str, size_t size, const char *format, ...)
const char *
malloc_vtprintf(const char *format, va_list ap)
{
- /* buf must be large enough for all possible uses within jemalloc. */
- static __thread char buf[4096];
+ static __thread char buf[MALLOC_PRINTF_BUFSIZE];
malloc_vsnprintf(buf, sizeof(buf), format, ap);