Skip to content

Commit

Permalink
static analysis fixes from clang scan-build
Browse files Browse the repository at this point in the history
  • Loading branch information
jpswinski committed Sep 26, 2023
1 parent 6febed0 commit 8a88173
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/core/ClusterSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ int ClusterSocket::onConnect(int fd)
if(!read_connections.add(fd, connection, false))
{
mlog(CRITICAL, "Cluster socket failed to register file descriptor for read connection due to duplicate entry");
delete connection;
status = -1;
}
}
Expand All @@ -625,8 +626,9 @@ int ClusterSocket::onConnect(int fd)
/* Add to Write Connections */
if(!write_connections.add(fd, connection, false))
{
mlog(CRITICAL, "Cluster socket failed to register file descriptor for read connection due to duplicate entry");
mlog(CRITICAL, "Cluster socket failed to register file descriptor for write connection due to duplicate entry");
if(role == WRITER && protocol == BUS && connection->subconnq) delete connection->subconnq;
delete connection;
status = -1;
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/core/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ bool HttpClient::makeRequest (EndpointObject::verb_t verb, const char* resource,
if(rqst_len <= MAX_RQST_BUF_LEN)
{
memcpy(rqstBuf, rqst_hdr.str(), hdr_len);
memcpy(&rqstBuf[hdr_len], data, content_length);
if(data) memcpy(&rqstBuf[hdr_len], data, content_length);
}
else
{
Expand Down Expand Up @@ -755,6 +755,8 @@ void* HttpClient::requestThread(void* parm)
}
}

delete request_sub;

return NULL;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/core/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,9 @@ int HttpServer::onConnect(int fd)
if(!connections.add(fd, connection, false))
{
mlog(CRITICAL, "HTTP server at %s failed to register connection due to duplicate entry", connection->id);
status = INVALID_RC; // will disconnect and free connection
deinitConnection(connection);
delete connection;
status = INVALID_RC;
}

return status;
Expand Down
7 changes: 5 additions & 2 deletions packages/core/LuaEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,11 @@ void LuaEngine::abortHook (lua_State *L, lua_Debug *ar)
lua_pushstring(L, LUA_SELFKEY);
lua_gettable(L, LUA_REGISTRYINDEX); /* retrieve value */
LuaEngine* li = (LuaEngine*)lua_touserdata(L, -1);
if(!li) luaL_error(L, "Unable to access Lua engine - aborting!");
if(!li->engineActive)
if(!li)
{
luaL_error(L, "Unable to access Lua engine - aborting!");
}
else if(!li->engineActive)
{
char error_msg[512];
StringLib::format(error_msg, 256, "Lua engine no longer active - exiting script <%s>", li->dInfo != NULL ? li->dInfo->script : li->pInfo->argv[0]);
Expand Down
2 changes: 1 addition & 1 deletion packages/netsvc/OrchestratorLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ OrchestratorLib::NodeList* OrchestratorLib::lock (const char* service, int nodes
mlog(CRITICAL, "Missing information from locked response; %d members != %d transactions", num_members, num_transactions);
}

if(verbose)
if(verbose && nodes)
{
for(int i = 0; i < nodes->length(); i++)
{
Expand Down

0 comments on commit 8a88173

Please sign in to comment.