修复字节对齐导致内存未初始化问题

This commit is contained in:
aozhiwei 2019-05-29 14:24:27 +08:00
parent 0d1fd33446
commit 7af5d3b84a

View File

@ -197,18 +197,19 @@ namespace f8
int packlen = msg.ByteSize();
assert(packlen < 1024 * 60);
char* buff = (char*)malloc(sizeof(WSProxyPackHead_S) + packlen);
char* buff = (char*)malloc(sizeof(WSProxyPackHead_C) + packlen);
memset(buff, 0, sizeof(WSProxyPackHead_C));
WSProxyPackHead_C* head = (WSProxyPackHead_C*)buff;
head->packlen = packlen;
head->msgid = msgid;
head->seqid = 0;
head->magic_code = MAGIC_CODE;
#if 0
head->rpc_error_code = 0;
#endif
head->ip_saddr = 0;
head->socket_handle = socket_handle;
msg.SerializeToArray(buff + sizeof(WSProxyPackHead_C), packlen);
if (packlen > 0) {
msg.SerializeToArray(buff + sizeof(WSProxyPackHead_C), packlen);
}
tcp_client->SendBuff(buff, sizeof(WSProxyPackHead_C) + packlen);
free(buff);
return sizeof(WSProxyPackHead_C) + packlen;