Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[atlesn] Fix misc. usage of uninitialized memory #180

Merged
merged 3 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ int convertToLeader(struct raft *r)
r->barrier.type = RAFT_BARRIER;
r->barrier.term = r->current_term;
r->barrier.buf.len = 8;
r->barrier.buf.base = raft_malloc(r->barrier.buf.len);
r->barrier.buf.base = raft_calloc(1, r->barrier.buf.len);
atlesn marked this conversation as resolved.
Show resolved Hide resolved

if (r->barrier.buf.base == NULL) {
rv = RAFT_NOMEM;
Expand Down
2 changes: 1 addition & 1 deletion src/uv_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ int uvEncodeMessage(const struct raft_message *message,
return RAFT_MALFORMED;
};

header.base = raft_malloc(header.len);
header.base = raft_calloc(1, header.len);
atlesn marked this conversation as resolved.
Show resolved Hide resolved
if (header.base == NULL) {
goto oom;
}
Expand Down
2 changes: 1 addition & 1 deletion src/uv_tcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static int uvTcpEncodeHandshake(raft_id id, const char *address, uv_buf_t *buf)
sizeof(uint64_t) + /* Server ID. */
sizeof(uint64_t) /* Size of the address buffer */;
buf->len += address_len;
buf->base = RaftHeapMalloc(buf->len);
buf->base = RaftHeapCalloc(1, buf->len);
atlesn marked this conversation as resolved.
Show resolved Hide resolved
if (buf->base == NULL) {
return RAFT_NOMEM;
}
Expand Down
Loading