Skip to content

Commit

Permalink
Fix possible null deref
Browse files Browse the repository at this point in the history
  • Loading branch information
wooffie committed Feb 24, 2025
1 parent 07df538 commit d3095e4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ natsConn_publish(natsConnection *nc, natsMsg *msg, const char *reply, bool direc
int hdrl = 0;
int totalLen = 0;

if (nc == NULL)
if (nc == NULL || msg == NULL)
return nats_setDefaultError(NATS_INVALID_ARG);

if ((msg->subject == NULL)
Expand Down Expand Up @@ -279,10 +279,9 @@ natsConnection_PublishString(natsConnection *nc, const char *subj,
natsStatus
natsConnection_PublishMsg(natsConnection *nc, natsMsg *msg)
{
const char *reply = (msg != NULL ? msg->reply : NULL);
natsStatus s;

s = _publishMsg(nc, msg, reply);
s = _publishMsg(nc, msg, NULL);
return NATS_UPDATE_ERR_STACK(s);
}

Expand Down

0 comments on commit d3095e4

Please sign in to comment.