From 50ba26a1720a71dd0e21d45c325c99a03d64edeb Mon Sep 17 00:00:00 2001 From: xywang Date: Mon, 6 Dec 2021 19:31:31 +0800 Subject: [PATCH] [TS-654]: fixed two crash bugs --- src/plugins/http/src/httpServer.c | 1 + src/rpc/src/rpcTcp.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/plugins/http/src/httpServer.c b/src/plugins/http/src/httpServer.c index 7f350a6f15..c00d8bdebd 100644 --- a/src/plugins/http/src/httpServer.c +++ b/src/plugins/http/src/httpServer.c @@ -409,6 +409,7 @@ static bool httpReadData(HttpContext *pContext) { continue; } else if (errno == EAGAIN || errno == EWOULDBLOCK) { httpDebug("context:%p, fd:%d, read from socket error:%d, wait another event", pContext, pContext->fd, errno); + httpReleaseContext(pContext/*, false */); return false; } else { httpError("context:%p, fd:%d, read from socket error:%d, close connect", pContext, pContext->fd, errno); diff --git a/src/rpc/src/rpcTcp.c b/src/rpc/src/rpcTcp.c index 2549518249..f74f2bbcc2 100644 --- a/src/rpc/src/rpcTcp.c +++ b/src/rpc/src/rpcTcp.c @@ -488,6 +488,12 @@ static int taosReadTcpData(SFdObj *pFdObj, SRecvInfo *pInfo) { msgLen = (int32_t)htonl((uint32_t)rpcHead.msgLen); int32_t size = msgLen + tsRpcOverhead; + // TODO: reason not found yet, workaround to avoid first + if (size < 0) { + tError("%s %p invalid size for malloc, msgLen:%d, size:%d", pThreadObj->label, pFdObj->thandle, msgLen, size); + return -1; + } + buffer = malloc(size); if (NULL == buffer) { tError("%s %p TCP malloc(size:%d) fail", pThreadObj->label, pFdObj->thandle, msgLen); -- GitLab