Commit 9979fa86 authored by Libor Peltan's avatar Libor Peltan

kjournalprint: fixed minor memleaks

parent 7f94fe8d
......@@ -1805,6 +1805,8 @@ int journal_db_list_zones(journal_db_t **db, list_t *zones)
}
if (list_size(zones) != expected_count) {
txn->ret = KNOT_EMALF;
ptrlist_deep_free(zones, NULL);
init_list(zones);
}
return txn->ret;
}
......
......@@ -61,10 +61,12 @@ static int reconfigure_mapsize(const char *journal_path, size_t *mapsize)
struct stat st;
if (stat(data_mdb, &st) != 0 || st.st_size == 0) {
fprintf(stderr, "Journal does not exist: %s\n", journal_path);
free(data_mdb);
return KNOT_ENOENT;
}
*mapsize = st.st_size + st.st_size / 8; // 112.5% to allow opening when growing
free(data_mdb);
return KNOT_EOK;
}
......@@ -82,11 +84,13 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color)
ret = reconfigure_mapsize(jdb->path, &jdb->fslimit);
if (ret != KNOT_EOK) {
journal_db_close(&jdb);
return ret;
}
ret = journal_open_db(&jdb);
if (ret != KNOT_EOK) {
journal_db_close(&jdb);
return ret;
}
......@@ -98,6 +102,7 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color)
size_t buflen = 8192;
char *buff = malloc(buflen);
if (buff == NULL) {
journal_db_close(&jdb);
return KNOT_ENOMEM;
}
journal_t *j = journal_new();
......@@ -185,11 +190,13 @@ int list_zones(char *path)
ret = reconfigure_mapsize(jdb->path, &jdb->fslimit);
if (ret != KNOT_EOK) {
journal_db_close(&jdb);
return ret;
}
ret = journal_open_db(&jdb);
if (ret != KNOT_EOK) {
journal_db_close(&jdb);
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment