Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/pub.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,12 @@ natsConnection_PublishString(natsConnection *nc, const char *subj,
natsStatus
natsConnection_PublishMsg(natsConnection *nc, natsMsg *msg)
{
const char *reply = (msg != NULL ? msg->reply : NULL);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rewrite this function and if msg == NULL return an invalid arg. The check of nc is done in the lower function, but could easily be added into this one.

As for removing the reply subject, of course we need it, but yes, the called function will take it from the provided message structure if not provided as a parameter, so I guess this change is ok.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kozlovic "rewrite this function" - you mean add the check/return before msg is even used and remove any conditionals like this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I meant what the contributor did, that is, check for msg == NULL as an invalid arg and return if that is the case. He did add the check for nc == NULL (although that is done in the internal function so that was not entirely necessary).

natsStatus s;

s = _publishMsg(nc, msg, reply);
if (nc == NULL || msg == NULL)
return nats_setDefaultError(NATS_INVALID_ARG);

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

Expand Down