Skip to content

Commit

Permalink
fix: some nulls checks (#840)
Browse files Browse the repository at this point in the history
* fix: some nulls checks

* fix: add null check for thread if oci already done

* fix: some nulls checks - remove redundant braces

* fix: some nulls checks - better if for sub.c
  • Loading branch information
wooffie authored Feb 18, 2025
1 parent 25682d6 commit 8943308
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ _processInfo(natsConnection *nc, char *info, int len)
tlsName = (const char*) nc->cur->url->host;

s = natsSrvPool_addNewURLs(nc->srvPool,
nc->cur->url,
nc->cur ? nc->cur->url : NULL,
nc->info.connectURLs,
nc->info.connectURLsCount,
tlsName,
Expand Down Expand Up @@ -3352,7 +3352,8 @@ _processUrlString(natsOptions *opts, const char *urls)

serverUrls = (char**) NATS_CALLOC(count + 1, sizeof(char*));
if (serverUrls == NULL)
s = NATS_NO_MEMORY;
return NATS_NO_MEMORY;

if (s == NATS_OK)
{
urlsCopy = NATS_STRDUP(urls);
Expand Down
6 changes: 4 additions & 2 deletions src/js.c
Original file line number Diff line number Diff line change
Expand Up @@ -3454,8 +3454,10 @@ _recreateOrderedCons(void *closure)

NATS_FREE(oci->ndlv);
NATS_FREE(oci);
natsThread_Detach(t);
natsThread_Destroy(t);
if (t != NULL) {
natsThread_Detach(t);
natsThread_Destroy(t);
}
natsSub_release(sub);
}

Expand Down
9 changes: 6 additions & 3 deletions src/sub.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,13 @@ natsSub_nextMsg(natsMsg **nextMsg, natsSubscription *sub, int64_t timeout, bool
if (s == NATS_OK)
{
msg = sub->ownDispatcher.queue.head;
if ((msg == NULL) && sub->draining)
if (msg == NULL)
{
removeSub = true;
s = NATS_TIMEOUT;
if (sub->draining)
{
removeSub = true;
s = NATS_TIMEOUT;
}
}
else
{
Expand Down

0 comments on commit 8943308

Please sign in to comment.