sep size may greater than buffer node, See Issue #286

This commit is contained in:
Cloud Wu
2015-06-03 09:42:49 +08:00
parent cc4756de35
commit 1fec2e6063

View File

@@ -190,7 +190,10 @@ pop_lstring(lua_State *L, struct socket_buffer *sb, int sz, int skip) {
}
break;
}
luaL_addlstring(&b, current->msg + sb->offset, (sz - skip < bytes) ? sz - skip : bytes);
int real_sz = sz - skip;
if (real_sz > 0) {
luaL_addlstring(&b, current->msg + sb->offset, (real_sz < bytes) ? real_sz : bytes);
}
return_free_node(L,2,sb);
sz-=bytes;
if (sz==0)