From fa6a9bb9341c5a834e211730bd33dad14040d3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 28 Jan 2023 22:18:14 +0100 Subject: api: readjust string size in function string_dyn_free when string is not freed (issue #1875) This frees some allocated memory if size_alloc was greater than size in the dynamic string. --- src/plugins/buflist/buflist-bar-item.c | 7 +++---- src/plugins/irc/irc-join.c | 5 +---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/buflist/buflist-bar-item.c b/src/plugins/buflist/buflist-bar-item.c index 1c7abf3c9..d7dcc0868 100644 --- a/src/plugins/buflist/buflist-bar-item.c +++ b/src/plugins/buflist/buflist-bar-item.c @@ -574,8 +574,7 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, -1); } } - str_hotlist = *hotlist; - weechat_string_dyn_free (hotlist, 0); + str_hotlist = weechat_string_dyn_free (hotlist, 0); } } weechat_hashtable_set ( @@ -655,15 +654,15 @@ buflist_bar_item_buflist_cb (const void *pointer, void *data, line_number++; } - str_buflist = *buflist; + str_buflist = weechat_string_dyn_free (buflist, 0); goto end; error: + weechat_string_dyn_free (buflist, 1); str_buflist = NULL; end: - weechat_string_dyn_free (buflist, 0); weechat_arraylist_free (buffers); if ((line_number_current_buffer != old_line_number_current_buffer[item_index]) diff --git a/src/plugins/irc/irc-join.c b/src/plugins/irc/irc-join.c index 82f8566b2..609c2b50c 100644 --- a/src/plugins/irc/irc-join.c +++ b/src/plugins/irc/irc-join.c @@ -372,10 +372,7 @@ irc_join_build_string (struct t_arraylist *arraylist) end: if (channels) - { - result = *channels; - weechat_string_dyn_free (channels, 0); - } + result = weechat_string_dyn_free (channels, 0); if (keys) weechat_string_dyn_free (keys, 1); -- cgit v1.2.3