about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2021-07-20 19:08:03 +0200
committerGitHub <noreply@github.com>2021-07-20 19:08:03 +0200
commit25cc479b2f22d25e863f940a9a4d3af71328e6c9 (patch)
tree0862e7c7c3a7b9edb06a91dfdea3e76b406adeef
parent8be49e9e21ef3a1de1bfc7a8af83add7080cfe80 (diff)
parent2e0adbd004ed950ec08a324a5a88e3e8cc462b86 (diff)
downloadprofani-tty-25cc479b2f22d25e863f940a9a4d3af71328e6c9.tar.gz
Merge pull request #1587 from profanity-im/memleak-history
Fix memory leak in chatwin when load history (#1585)
-rw-r--r--src/ui/chatwin.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ui/chatwin.c b/src/ui/chatwin.c
index 47345709..4dfe50ed 100644
--- a/src/ui/chatwin.c
+++ b/src/ui/chatwin.c
@@ -519,7 +519,11 @@ _chatwin_history(ProfChatWin* chatwin, const char* const contact_barejid)
 
         while (curr) {
             ProfMessage* msg = curr->data;
+            char *msg_plain = msg->plain;
             msg->plain = plugins_pre_chat_message_display(msg->from_jid->barejid, msg->from_jid->resourcepart, msg->plain);
+            // This is dirty workaround for memory leak. We reassign msg->plain above so have to free previous object
+            // TODO: Make a better solution, for example, pass msg object to the function and it will replace msg->plain properly if needed.
+            free(msg_plain);
             win_print_history((ProfWin*)chatwin, msg);
             curr = g_slist_next(curr);
         }