pidgin/pidgin

d10bb378f560
Parents a4a68d315090
Children e6f8e92dccf3
Fix some null pointer deferences and dead stores that scanbuild found in Pidgin

Testing Done:
Verified scanbuild no long detected the errors.

Reviewed at https://reviews.imfreedom.org/r/719/
--- a/pidgin/gtkaccount.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/gtkaccount.c Thu Jun 03 19:33:07 2021 -0500
@@ -553,7 +553,7 @@
const char *value = NULL;
char *c;
- if (dialog->account != NULL) {
+ if (username != NULL && dialog->account != NULL) {
if(purple_account_user_split_get_reverse(split))
c = strrchr(username,
purple_account_user_split_get_separator(split));
--- a/pidgin/gtkblist.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/gtkblist.c Thu Jun 03 19:33:07 2021 -0500
@@ -3138,7 +3138,7 @@
return FALSE;
}
- height = width = 0;
+ height = 0;
for (list = gtkblist->tooltipdata; list; list = list->next) {
struct tooltip_data *td = list->data;
max_text_width = MAX(max_text_width, MAX(td->width, td->name_width));
@@ -6451,7 +6451,7 @@
PurpleGroup *group;
gboolean selected;
char group_count[12] = "";
- char *mark, *esc;
+ char *mark, *esc = NULL;
PurpleBlistNode *selected_node = NULL;
GtkTreeIter iter;
PidginThemeFont *pair;
@@ -6484,7 +6484,10 @@
text_color = selected ? NULL : theme_font_get_color_default(pair, NULL);
text_font = theme_font_get_face_default(pair, "");
- esc = g_markup_escape_text(group->name, -1);
+ if(group != NULL) {
+ esc = g_markup_escape_text(group->name, -1);
+ }
+
if (text_color) {
mark = g_strdup_printf("<span foreground='%s' font_desc='%s'><b>%s</b>%s%s%s</span>",
text_color, text_font,
--- a/pidgin/gtkimhtml.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/gtkimhtml.c Thu Jun 03 19:33:07 2021 -0500
@@ -354,7 +354,9 @@
} else
index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str);
- t = t->children [index];
+ if(t->children != NULL) {
+ t = t->children [index];
+ }
x++;
} while (*x);
@@ -544,7 +546,7 @@
PangoLayout *layout;
PangoFont *font;
- gint gap, x, y, h, w, scr_w, baseline_skip;
+ gint x, y, h, w, scr_w, baseline_skip;
g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE);
@@ -598,11 +600,7 @@
font_metrics = pango_font_get_metrics(font, NULL);
pango_layout_get_pixel_size(layout, &scr_w, NULL);
- gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) +
- pango_font_metrics_get_descent(font_metrics))/ 4);
-
- if (gap < 2)
- gap = 2;
+
baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) +
pango_font_metrics_get_descent(font_metrics));
w = 8 + scr_w;
@@ -2735,7 +2733,8 @@
if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD))
gtk_imhtml_toggle_bold(imhtml);
bold++;
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
}
break;
case 3: /* /B */
@@ -2743,7 +2742,8 @@
case 55: /* /STRONG */
if (!(options & GTK_IMHTML_NO_FORMATTING)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if (bold) {
bold--;
@@ -2757,7 +2757,8 @@
case 52: /* EM */
if (!(options & GTK_IMHTML_NO_FORMATTING)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC))
gtk_imhtml_toggle_italic(imhtml);
italics++;
@@ -2768,7 +2769,8 @@
case 53: /* /EM */
if (!(options & GTK_IMHTML_NO_FORMATTING)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if (italics) {
italics--;
if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo)
@@ -2780,7 +2782,8 @@
case 10: /* UNDERLINE */
if (!(options & GTK_IMHTML_NO_FORMATTING)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE))
gtk_imhtml_toggle_underline(imhtml);
underline++;
@@ -2790,7 +2793,8 @@
case 12: /* /UNDERLINE */
if (!(options & GTK_IMHTML_NO_FORMATTING)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if (underline) {
underline--;
if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo)
@@ -2801,7 +2805,8 @@
case 13: /* S */
case 14: /* STRIKE */
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE))
gtk_imhtml_toggle_strike(imhtml);
strike++;
@@ -2809,7 +2814,8 @@
case 15: /* /S */
case 16: /* /STRIKE */
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if (strike)
strike--;
if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo)
@@ -2887,7 +2893,8 @@
gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml));
scalable->scale(scalable, rect.width - minus, rect.height);
imhtml->scalables = g_list_append(imhtml->scalables, sd);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
ws[wpos++] = '\n';
break;
@@ -2896,7 +2903,8 @@
if (fonts && !imhtml->wbfo) {
GtkIMHtmlFontDetail *font = fonts->data;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT (NEW_TEXT_BIT); */
if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) {
@@ -2936,7 +2944,8 @@
case 28: /* /A */
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
gtk_imhtml_toggle_link(imhtml, NULL);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
break;
case 30: /* /P */
@@ -2948,7 +2957,8 @@
break;
case 36: /* /BODY */
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
gtk_imhtml_toggle_background(imhtml, NULL);
break;
case 37: /* FONT */
@@ -2970,7 +2980,8 @@
break;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
font = g_new0 (GtkIMHtmlFontDetail, 1);
if (fonts)
@@ -3029,7 +3040,8 @@
char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR=");
if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT(NEW_TEXT_BIT); */
g_free(bg);
bg = bgcolor;
@@ -3043,7 +3055,8 @@
gchar *href = gtk_imhtml_get_html_opt (tag, "HREF=");
if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
gtk_imhtml_toggle_link(imhtml, href);
}
g_free(href);
@@ -3055,7 +3068,8 @@
char *id;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
if (!(imhtml->format_functions & GTK_IMHTML_IMAGE))
break;
@@ -3124,7 +3138,8 @@
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT (NEW_TEXT_BIT); */
/* Bi-Directional text support */
@@ -3136,7 +3151,8 @@
ws[wpos++] = 0xAB;
ws[wpos] = '\0';
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
}
g_free(direction);
@@ -3285,7 +3301,8 @@
GtkIMHtmlFontDetail *oldfont = NULL;
GtkIMHtmlFontDetail *font = fonts->data;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT (NEW_TEXT_BIT); */
fonts = g_slist_remove (fonts, font);
if (fonts)
@@ -3356,7 +3373,8 @@
gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL);
}
#endif
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT (NEW_COMMENT_BIT); */
break;
@@ -3382,7 +3400,7 @@
sml = imhtml->protocol_name;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- wpos = g_snprintf (ws, smilelen + 1, "%s", c);
+ g_snprintf (ws, smilelen + 1, "%s", c);
gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter);
@@ -3402,7 +3420,8 @@
ws[wpos] = '\n';
wpos++;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT (NEW_TEXT_BIT); */
} else if (!br) { /* Don't insert a space immediately after an HTML break */
/* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary.
@@ -3413,7 +3432,8 @@
ws[wpos] = ' ';
wpos++;
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
}
c++;
pos++;
@@ -3424,7 +3444,8 @@
br = FALSE;
if (wpos > 0) {
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
}
while (len_protocol--) {
/* Skip the next len_protocol characters, but
@@ -3449,7 +3470,8 @@
ws[wpos] = '\0';
gtk_imhtml_toggle_link(imhtml, ws);
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
gtk_imhtml_toggle_link(imhtml, NULL);
}
} else if (*c) {
@@ -3461,7 +3483,8 @@
}
}
gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
+ wpos = 0;
/* NEW_BIT(NEW_TEXT_BIT); */
@@ -3487,7 +3510,7 @@
ws[wpos] = '\0';
gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos);
gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter);
- ws[0] = '\0'; wpos = 0;
+ ws[0] = '\0';
}
while (fonts) {
--- a/pidgin/gtknotify.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/gtknotify.c Thu Jun 03 19:33:07 2021 -0500
@@ -724,7 +724,10 @@
tmp = g_markup_escape_text(*subjects, -1);
subject_text = g_strdup_printf("%s<b>%s</b>: %s", first ? "<br>" : "", _("Subject"), tmp);
g_free(tmp);
- first = FALSE;
+ /* this is a dead assignment, but if you add another row you'll
+ * need it, so I commented it out for now.
+ */
+ /* first = FALSE; */
subjects++;
}
#define SAFE(x) ((x) ? (x) : "")
@@ -751,7 +754,7 @@
notification = g_strdup_printf(ngettext("%s has %d new message.",
"%s has %d new messages.",
(int)count),
- *tos, (int)count);
+ tos != NULL ? *tos : NULL, (int)count);
data2 = pidgin_notify_add_mail(mail_dialog->treemodel, account, notification, urls ? *urls : NULL, count, FALSE, &new_data);
if (data2 && new_data) {
if (data)
--- a/pidgin/plugins/gevolution/assoc-buddy.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/plugins/gevolution/assoc-buddy.c Thu Jun 03 19:33:07 2021 -0500
@@ -133,7 +133,6 @@
populate_treeview(GevoAssociateBuddyDialog *dialog, const gchar *uid) {
EBook *book;
EBookQuery *query;
- const char *prpl_id;
gboolean status;
GList *cards, *c;
GError *err = NULL;
@@ -186,8 +185,6 @@
return;
}
- prpl_id = purple_account_get_protocol_id(dialog->buddy->account);
-
for (c = cards; c != NULL; c = c->next)
{
EContact *contact = E_CONTACT(c->data);
--- a/pidgin/plugins/transparency.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/plugins/transparency.c Thu Jun 03 19:33:07 2021 -0500
@@ -76,7 +76,10 @@
/* Set window transparency level */
static void set_wintrans(GtkWidget *window, int alpha, gboolean enabled,
- gboolean always_on_top) {
+ gboolean always_on_top)
+{
+ g_return_if_fail(GTK_IS_WIDGET(window));
+
if (enabled) {
gdk_window_set_opacity(window->window, alpha / 255.0);
gdk_window_set_keep_above(window->window, always_on_top);
@@ -530,7 +533,7 @@
G_CALLBACK(update_convs_wintrans),
(gpointer) OPT_WINTRANS_IM_SLIDER);
- button = pidgin_prefs_checkbox(
+ pidgin_prefs_checkbox(
_("Remove IM window transparency on focus"),
OPT_WINTRANS_IM_ONFOCUS, trans_box);
@@ -579,7 +582,7 @@
gtk_widget_show(trans_box);
g_signal_connect(GTK_OBJECT(button), "clicked",
G_CALLBACK(pidgin_toggle_sensitive), trans_box);
- button = pidgin_prefs_checkbox(
+ pidgin_prefs_checkbox(
_("Remove Buddy List window transparency on focus"),
OPT_WINTRANS_BL_ONFOCUS, trans_box);
button = pidgin_prefs_checkbox(_("Always on top"), OPT_WINTRANS_BL_ONTOP,
--- a/pidgin/plugins/vvconfig.c Thu Jun 03 19:31:56 2021 -0500
+++ b/pidgin/plugins/vvconfig.c Thu Jun 03 19:33:07 2021 -0500
@@ -254,7 +254,13 @@
devices = get_element_devices(value);
if (g_list_find_custom(devices, purple_prefs_get_string(pref),
(GCompareFunc)strcmp) == NULL)
- purple_prefs_set_string(pref, g_list_next(devices)->data);
+ {
+ GList *next = g_list_next(devices);
+
+ if(next != NULL) {
+ purple_prefs_set_string(pref, next->data);
+ }
+ }
widget = pidgin_prefs_dropdown_from_list(parent,
label, PURPLE_PREF_STRING,
pref, devices);
@@ -292,7 +298,12 @@
devices = get_element_devices(purple_prefs_get_string(plugin_pref));
if (g_list_find_custom(devices, purple_prefs_get_string(device_pref),
(GCompareFunc) strcmp) == NULL)
- purple_prefs_set_string(device_pref, g_list_next(devices)->data);
+ {
+ GList *next = g_list_next(devices);
+ if(next != NULL) {
+ purple_prefs_set_string(device_pref, next->data);
+ }
+ }
widget = pidgin_prefs_dropdown_from_list(vbox, device_label,
PURPLE_PREF_STRING, device_pref, devices);
g_list_free(devices);