From d5f8202c691dd2c41f538b4b8128fde98f0895f3 Mon Sep 17 00:00:00 2001 From: Reuh Date: Fri, 23 Oct 2015 21:02:27 +0200 Subject: [PATCH] Fixed tcpsocketobject:received when receiving less data than passed at arguments It cuts the string at the end of received data. --- source/socket.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/socket.c b/source/socket.c index d921c1c..5c69cec 100644 --- a/source/socket.c +++ b/source/socket.c @@ -200,7 +200,8 @@ static int socket_receive(lua_State *L) { } 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); return 1;