From 8718ef85a01b73fb0edfb65b517479130a76c595 Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Mon, 8 Jul 2019 15:15:29 +0200 Subject: [PATCH] fix a few memory leaks --- libdc/src/account.c | 2 +- libdc/src/api-friends.c | 4 +++- ncdc/src/msg.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libdc/src/account.c b/libdc/src/account.c index 4fac0aa..b1205a1 100644 --- a/libdc/src/account.c +++ b/libdc/src/account.c @@ -296,7 +296,7 @@ void dc_account_set_friends(dc_account_t a, dc_account_t *friends, size_t len) g_ptr_array_remove_range(a->friends, 0, a->friends->len); for (i = 0; i < len; i++) { - g_ptr_array_add(a->friends, friends[i]); + g_ptr_array_add(a->friends, dc_ref(friends[i])); } } diff --git a/libdc/src/api-friends.c b/libdc/src/api-friends.c index 94d109d..f529d1c 100644 --- a/libdc/src/api-friends.c +++ b/libdc/src/api-friends.c @@ -53,7 +53,9 @@ bool dc_api_get_friends(dc_api_t api, dc_account_t login) cleanup: - g_ptr_array_free(f, FALSE); + if (f != NULL) { + g_ptr_array_unref(f); + } json_decref(reply); reply = NULL; diff --git a/ncdc/src/msg.c b/ncdc/src/msg.c index d1e0b90..f69f200 100644 --- a/ncdc/src/msg.c +++ b/ncdc/src/msg.c @@ -57,8 +57,8 @@ bool ncdc_cmd_msg(ncdc_mainwindow_t n, size_t ac, wchar_t **av) v = ncdc_textview_new(); goto_if_true(v == NULL, cleanup); - ncdc_textview_set_account(v, dc_ref(current_account)); - ncdc_textview_set_channel(v, dc_ref(c)); + ncdc_textview_set_account(v, current_account); + ncdc_textview_set_channel(v, c); g_ptr_array_add(ncdc_mainwindow_views(n), dc_ref(v)); ncdc_mainwindow_switchview(n, ncdc_mainwindow_views(n)->len-1);