From: Andre Noll Date: Mon, 29 Feb 2016 18:26:09 +0000 (+0100) Subject: string.c: Alloc space for terminating null wide character. X-Git-Tag: v0.5.6~53 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;ds=inline;h=9b8cece0f67b0445dd66a9d2a89b9e69d2540173;p=paraslash.git string.c: Alloc space for terminating null wide character. Should not matter since we already know the number of wide characters and never look past the allocated buffer. But let's be conservative here and allocate space for the terminating null wide character. --- diff --git a/string.c b/string.c index c820bdca..701448e0 100644 --- a/string.c +++ b/string.c @@ -1073,7 +1073,7 @@ __must_check int strwidth(const char *s, size_t *result) return -ERRNO_TO_PARA_ERROR(errno); if (num_wchars == 0) return 0; - dest = para_malloc(num_wchars * sizeof(*dest)); + dest = para_malloc((num_wchars + 1) * sizeof(*dest)); src = s; memset(&state, 0, sizeof(state)); num_wchars = mbsrtowcs(dest, &src, num_wchars, &state);