Skip to content

Commit

Permalink
Merge pull request #508 from paoloteti/fix-error-handling
Browse files Browse the repository at this point in the history
[FIXED] Coverity Scan unchecked return value
  • Loading branch information
kozlovic authored Jan 24, 2022
2 parents debd46d + da9d24b commit a551fa9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ natsMsgHeader_encode(natsBuffer *buf, natsMsg *msg)
// See explanation in natsMsgHeader_encodedLen()
if (natsMsg_needsLift(msg))
{
natsBuf_Append(buf, (const char*) msg->hdr, msg->hdrLen);
s = natsBuf_Append(buf, (const char*) msg->hdr, msg->hdrLen);
return NATS_UPDATE_ERR_STACK(s);
}

Expand Down
3 changes: 2 additions & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,9 +1967,10 @@ nats_ReadFile(natsBuffer **buffer, int initBufSize, const char *fn)
else if (fclose(f) != 0)
s = nats_setError(NATS_ERR, "error closing file '%s': '%s", fn, strerror(errno));

IFOK(s, natsBuf_AppendByte(buf, '\0'));

if (s == NATS_OK)
{
natsBuf_AppendByte(buf, '\0');
*buffer = buf;
}
else if (buf != NULL)
Expand Down

0 comments on commit a551fa9

Please sign in to comment.