From ead32d63209133fa83dbb43debd4db33b363d887 Mon Sep 17 00:00:00 2001 From: sin Date: Fri, 6 Mar 2015 12:39:11 +0000 Subject: Fix some checks in wchar.h Some of these functions allow the destination pointer to be NULL. Do not trap in that case as nothing will be written to the destination buffer. --- include/wchar.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/wchar.h b/include/wchar.h index 16895e5..ca9840a 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -59,7 +59,7 @@ __fortify_mbstowcs(wchar_t *ws, const char *s, size_t wn) { size_t bos = __builtin_object_size(ws, 0); - if (wn > bos / sizeof(wchar_t)) + if (ws && wn > bos / sizeof(wchar_t)) __builtin_trap(); return mbstowcs(ws, s, wn); } @@ -70,7 +70,7 @@ __fortify_wcrtomb(char *s, wchar_t wc, mbstate_t *st) { size_t bos = __builtin_object_size(s, 0); - if (MB_CUR_MAX > bos) + if (s && MB_CUR_MAX > bos) __builtin_trap(); return wcrtomb(s, wc, st); } @@ -167,7 +167,7 @@ __fortify_wcstombs(char *s, const wchar_t *ws, size_t n) { size_t bos = __builtin_object_size(s, 0); - if (n > bos) + if (s && n > bos) __builtin_trap(); return wcstombs(s, ws, n); } @@ -178,7 +178,7 @@ __fortify_wctomb(char *s, wchar_t wc) { size_t bos = __builtin_object_size(s, 0); - if (MB_CUR_MAX > bos) + if (s && MB_CUR_MAX > bos) __builtin_trap(); return wctomb(s, wc); } -- cgit v1.3