pidgin/pidgin

Fix some issues scanbuild found in gtkconv.c
release-2.x.y
2021-06-01, Gary Kramlich
f1ffe1b5a9d8
Parents f25ce9376564
Children 5c79001c7e86
Fix some issues scanbuild found in gtkconv.c

Testing Done:
Verified that scanbuild no longer detected the errors.

Reviewed at https://reviews.imfreedom.org/r/695/
--- a/pidgin/gtkconv.c Tue Jun 01 17:34:45 2021 -0500
+++ b/pidgin/gtkconv.c Tue Jun 01 17:35:17 2021 -0500
@@ -3976,7 +3976,6 @@
PidginChatPane *gtkchat;
PurpleConvChat *chat;
PurpleConnection *gc;
- PurplePluginProtocolInfo *prpl_info;
GtkTreeModel *tm;
GtkListStore *ls;
GtkTreePath *newpath;
@@ -3997,7 +3996,7 @@
gtkchat = gtkconv->u.chat;
gc = purple_conversation_get_gc(conv);
- if (!gc || !(prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)))
+ if (!gc || !(PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl)))
return;
tm = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list));
@@ -4275,10 +4274,15 @@
while (matches) {
char *tmp = addthis;
+ gpointer data;
+
addthis = g_strconcat(tmp, matches->data, " ", NULL);
+
g_free(tmp);
- g_free(matches->data);
+
+ data = matches->data;
matches = g_list_remove(matches, matches->data);
+ g_free(data);
}
purple_conversation_write(conv, NULL, addthis, PURPLE_MESSAGE_NO_LOG,
@@ -5967,7 +5971,6 @@
char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup(""));
/* The initial offset is to deal with
* escaped entities making the string longer */
- int tag_start_offset = 0;
const char *tagname = NULL;
GtkTextIter start, end;
@@ -5984,25 +5987,18 @@
/* If we're whispering, it's not an autoresponse. */
if (purple_message_meify(new_message, -1 )) {
g_snprintf(str, 1024, "***%s", alias_escaped);
- tag_start_offset += 3;
tagname = "whisper-action-name";
}
else {
g_snprintf(str, 1024, "*%s*:", alias_escaped);
- tag_start_offset += 1;
-#if 0
- tag_end_offset = 2;
-#endif
tagname = "whisper-name";
}
} else {
if (purple_message_meify(new_message, -1)) {
if (flags & PURPLE_MESSAGE_AUTO_RESP) {
g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped);
- tag_start_offset += strlen(AUTO_RESPONSE) - 6 + 4;
} else {
g_snprintf(str, 1024, "***%s", alias_escaped);
- tag_start_offset += 3;
}
if (flags & PURPLE_MESSAGE_NICK)
@@ -6012,12 +6008,8 @@
} else {
if (flags & PURPLE_MESSAGE_AUTO_RESP) {
g_snprintf(str, 1024, "%s %s", alias_escaped, AUTO_RESPONSE);
- tag_start_offset += strlen(AUTO_RESPONSE) - 6 + 1;
} else {
g_snprintf(str, 1024, "%s:", alias_escaped);
-#if 0
- tag_end_offset = 1;
-#endif
}
if (flags & PURPLE_MESSAGE_NICK) {
@@ -6081,7 +6073,11 @@
memcpy(with_font_tag + pre_len, new_message, length);
strcpy(with_font_tag + pre_len + length, post);
- length += pre_len + post_len;
+ /* Previously this might have been used later in the fuction, so
+ * I'm just commenting it for now. -- GK 2021-06-01
+ */
+ /* length += pre_len + post_len; */
+
g_free(pre);
} else
with_font_tag = g_memdup2(new_message, length);