I have the following code
char *GetBytesString(char message[])
{
wchar_t utf16_str;
char *ptr;
mbstowcs(&utf16_str, message, sizeof(message));
ptr = (char *) malloc(sizeof(utf16_str) + 2);
memcpy(ptr, &utf16_str, sizeof(utf16_str));
return ptr;
}
Whenever I try to call it, I get an error saying that Heap corruption has occurred around utf16_str. What can I do to fix it?
Thanks!