Skip to content

Commit

Permalink
Fix memory leaks in productdb.c
Browse files Browse the repository at this point in the history
* When reading of JSON file fails, then do not forget to free
  object representing JSON file.

Fix indentation.
  • Loading branch information
jirihnidek committed Mar 6, 2024
1 parent d326b05 commit b7a3596
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/plugins/libdnf/productdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (repoIds == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
GSList *repoList = NULL;
Expand All @@ -109,6 +110,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (idArray == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
int len = array_list_length(idArray);
Expand All @@ -119,6 +121,7 @@ void readProductDb(ProductDb *productDb, GError **err) {
if (repoId == NULL) {
*err = g_error_new_literal(quark, 0, error_string);
g_free(productId);
json_object_put(dbJson);
return;
}
repoList = g_slist_prepend(repoList, (gpointer) repoId);
Expand Down

0 comments on commit b7a3596

Please sign in to comment.