From 9b8cece0f67b0445dd66a9d2a89b9e69d2540173 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Mon, 29 Feb 2016 19:26:09 +0100 Subject: [PATCH] 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. --- string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); -- 2.39.5