开发者

mbstowcs_s is causing my program to crash

开发者 https://www.devze.com 2023-01-29 02:25 出处:网络
This i开发者_JAVA技巧s the relevant code: char c; size_t buffer_size = 0; wchar_t* wc = (wchar_t*) malloc(buffer_size);

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号