hirc

IRC client
Log | Files | Refs

commit ccc6a0eca3ad29a37df8e25129148ddea0449a4b
parent c01789e1a173145ccf3096889649d0cec7c940e9
Author: hhvn <dev@hhvn.uk>
Date:   Tue, 24 May 2022 21:13:53 +0100

stowc()/wctos(): fail gracefully on invalid string

Diffstat:
Msrc/mem.c | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/mem.c b/src/mem.c @@ -103,6 +103,7 @@ stowc(char *str) { if (!str) return NULL; len = mbstowcs(NULL, str, 0) + 1; + if (!len) return NULL; ret = emalloc(len * sizeof(wchar_t)); mbstowcs(ret, str, len); return ret; @@ -116,6 +117,7 @@ wctos(wchar_t *str) { if (!str) return NULL; len = wcstombs(NULL, str, 0) + 1; + if (!len) return NULL; ret = emalloc(len); wcstombs(ret, str, len); return ret;