1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-27 16:39:29 +00:00

Fixed tcpsocketobject:received when receiving less data than passed at arguments

It cuts the string at the end of received data.
This commit is contained in:
Reuh 2015-10-23 21:02:27 +02:00
parent a8d31de1e4
commit d5f8202c69

View file

@ -200,7 +200,8 @@ static int socket_receive(lua_State *L) {
} }
char *buff = malloc(count); char *buff = malloc(count);
recv(userdata->socket, buff, count, flags); int len = recv(userdata->socket, buff, count, flags);
*(buff+len) = 0x0; // text end
lua_pushstring(L, buff); lua_pushstring(L, buff);
return 1; return 1;