Skip to content

Commit df12f34

Browse files
author
Reini Urban
committed
api_string_export_wchar allocated one too less
clang -faddress-sanitizer detected this heap-buffer-overflow in t/src/embed/strings.t, allocated 173 bytes only, writing to cstr[173].
1 parent 5810fe5 commit df12f34

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/embed/strings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Parrot_api_string_export_wchar(ARGIN(Parrot_PMC interp_pmc), ARGIN(Parrot_String
102102
cstr = Parrot_str_to_cstring(interp, string);
103103
len = strlen(cstr);
104104

105-
wstrout = (wchar_t *) malloc(sizeof (wchar_t) * len + 1);
105+
wstrout = (wchar_t *) malloc(sizeof (wchar_t) * (len + 1));
106106
mbstowcs(wstrout, cstr, len);
107107
wstrout[len] = L'\0';
108108

0 commit comments

Comments
 (0)