This i开发者_JAVA技巧s the relevant code:
char c;
size_t buffer_size = 0;
wchar_t* wc = (wchar_t*) malloc(buffer_size);
int result = recv(this->m_socket, &c, 1, 0);
mbstowcs_s(&buffer_size, wc, buffer_size, &c, 1); // Something is wrong here
How do I fix this?
You allocated 0 bytes for wc
and passed that buffer to mbstowcs_s
.
i had the same problem. the problem is in the last parameter that rappresents "The maximum number of wide characters to store in the wcstr buffer, not including the terminating null, or _TRUNCATE."
http://msdn.microsoft.com/en-us/library/eyktyxsx%28v=vs.80%29.aspx
精彩评论