Skip to content
Snippets Groups Projects
Commit 67285b2b authored by Ondřej Surý's avatar Ondřej Surý
Browse files

memset() after checking the result of malloc()

parent 7c0ab14f
No related branches found
No related tags found
No related merge requests found
......@@ -327,13 +327,13 @@ journal_t* journal_open(const char *fn, size_t fslimit, int mode, uint16_t bflag
/* Allocate journal structure. */
const size_t node_len = sizeof(journal_node_t);
journal_t *j = malloc(sizeof(journal_t) + max_nodes * node_len);
memset(j, 0, sizeof(journal_t) + max_nodes * node_len);
if (!j) {
if (j == NULL) {
dbg_journal_detail("journal: cannot allocate journal\n");
fcntl(fd, F_SETLK, &fl);
close(fd);
return NULL;
}
memset(j, 0, sizeof(journal_t) + max_nodes * node_len);
j->qhead = j->qtail = 0;
j->fd = fd;
j->max_nodes = max_nodes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment