bugfix: not padding 0

This commit is contained in:
Cloud Wu
2014-10-13 17:55:54 +08:00
parent c458eba6b4
commit 31d7b648b4
2 changed files with 2 additions and 3 deletions

View File

@@ -368,7 +368,7 @@ lunpack(lua_State *L) {
lua_pushinteger(L, message->id);
lua_pushinteger(L, message->ud);
if (message->buffer == NULL) {
lua_pushlstring(L, (char *)(message+1),size - sizeof(*message) - 1);
lua_pushlstring(L, (char *)(message+1),size - sizeof(*message));
} else {
lua_pushlightuserdata(L, message->buffer);
}

View File

@@ -36,10 +36,9 @@ forward_message(int type, bool padding, struct socket_message * result) {
int sz = sizeof(*sm);
if (padding) {
if (result->data) {
sz += strlen(result->data) + 1;
sz += strlen(result->data);
} else {
result->data = "";
sz += 1;
}
}
sm = (struct skynet_socket_message *)skynet_malloc(sz);