Mercurial > pidgin.yaz
comparison pidgin/gtkutils.c @ 28526:07718e5eb8ce
Fix various leaks of the basename/filename/entire list in pidgin_dnd_file_manage.
These were pointed out by WebcamWonder.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Wed, 02 Sep 2009 03:17:25 +0000 |
parents | d4036e0f58d6 |
children | 612402e064cb 5ceac3a20b93 |
comparison
equal
deleted
inserted
replaced
28525:5546612e70e2 | 28526:07718e5eb8ce |
---|---|
1531 } | 1531 } |
1532 | 1532 |
1533 void | 1533 void |
1534 pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who) | 1534 pidgin_dnd_file_manage(GtkSelectionData *sd, PurpleAccount *account, const char *who) |
1535 { | 1535 { |
1536 GList *tmp; | |
1537 GdkPixbuf *pb; | 1536 GdkPixbuf *pb; |
1538 GList *files = purple_uri_list_extract_filenames((const gchar *)sd->data); | 1537 GList *files = purple_uri_list_extract_filenames((const gchar *)sd->data); |
1539 PurpleConnection *gc = purple_account_get_connection(account); | 1538 PurpleConnection *gc = purple_account_get_connection(account); |
1540 PurplePluginProtocolInfo *prpl_info = NULL; | 1539 PurplePluginProtocolInfo *prpl_info = NULL; |
1541 gboolean file_send_ok = FALSE; | 1540 gboolean file_send_ok = FALSE; |
1542 #ifndef _WIN32 | 1541 #ifndef _WIN32 |
1543 PurpleDesktopItem *item; | 1542 PurpleDesktopItem *item; |
1544 #endif | 1543 #endif |
1544 gchar *filename = NULL; | |
1545 gchar *basename = NULL; | |
1545 | 1546 |
1546 g_return_if_fail(account != NULL); | 1547 g_return_if_fail(account != NULL); |
1547 g_return_if_fail(who != NULL); | 1548 g_return_if_fail(who != NULL); |
1548 | 1549 |
1549 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { | 1550 for ( ; files; files = g_list_delete_link(files, files)) { |
1550 gchar *filename = tmp->data; | 1551 g_free(filename); |
1551 gchar *basename = g_path_get_basename(filename); | 1552 g_free(basename); |
1553 | |
1554 filename = files->data; | |
1555 basename = g_path_get_basename(filename); | |
1552 | 1556 |
1553 /* Set the default action: don't send anything */ | 1557 /* Set the default action: don't send anything */ |
1554 file_send_ok = FALSE; | 1558 file_send_ok = FALSE; |
1555 | 1559 |
1556 /* XXX - Make ft API support creating a transfer with more than one file */ | 1560 /* XXX - Make ft API support creating a transfer with more than one file */ |
1569 purple_notify_error(NULL, NULL, | 1573 purple_notify_error(NULL, NULL, |
1570 str, str2); | 1574 str, str2); |
1571 | 1575 |
1572 g_free(str); | 1576 g_free(str); |
1573 g_free(str2); | 1577 g_free(str2); |
1574 | |
1575 continue; | 1578 continue; |
1576 } | 1579 } |
1577 | 1580 |
1578 /* Are we dealing with an image? */ | 1581 /* Are we dealing with an image? */ |
1579 pb = gdk_pixbuf_new_from_file(filename, NULL); | 1582 pb = gdk_pixbuf_new_from_file(filename, NULL); |
1627 data, | 1630 data, |
1628 _("Set as buddy icon"), DND_BUDDY_ICON, | 1631 _("Set as buddy icon"), DND_BUDDY_ICON, |
1629 (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), | 1632 (ft ? _("Send image file") : _("Insert in message")), (ft ? DND_FILE_TRANSFER : DND_IM_IMAGE), |
1630 NULL); | 1633 NULL); |
1631 g_object_unref(G_OBJECT(pb)); | 1634 g_object_unref(G_OBJECT(pb)); |
1635 | |
1636 g_free(basename); | |
1637 while (files) { | |
1638 g_free(files->data); | |
1639 files = g_list_delete_link(files, files); | |
1640 } | |
1632 return; | 1641 return; |
1633 } | 1642 } |
1634 | 1643 |
1635 #ifndef _WIN32 | 1644 #ifndef _WIN32 |
1636 /* Are we trying to send a .desktop file? */ | 1645 /* Are we trying to send a .desktop file? */ |
1684 "of this launcher instead of this " | 1693 "of this launcher instead of this " |
1685 "launcher itself.")); | 1694 "launcher itself.")); |
1686 break; | 1695 break; |
1687 } | 1696 } |
1688 purple_desktop_item_unref(item); | 1697 purple_desktop_item_unref(item); |
1698 g_free(basename); | |
1699 while (files) { | |
1700 g_free(files->data); | |
1701 files = g_list_delete_link(files, files); | |
1702 } | |
1689 return; | 1703 return; |
1690 } | 1704 } |
1691 #endif /* _WIN32 */ | 1705 #endif /* _WIN32 */ |
1692 | 1706 |
1693 /* Everything is fine, let's send */ | 1707 /* Everything is fine, let's send */ |
1694 serv_send_file(gc, who, filename); | 1708 serv_send_file(gc, who, filename); |
1695 g_free(filename); | 1709 } |
1696 } | 1710 |
1697 g_list_free(files); | 1711 g_free(filename); |
1712 g_free(basename); | |
1698 } | 1713 } |
1699 | 1714 |
1700 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height) | 1715 void pidgin_buddy_icon_get_scale_size(GdkPixbuf *buf, PurpleBuddyIconSpec *spec, PurpleIconScaleRules rules, int *width, int *height) |
1701 { | 1716 { |
1702 *width = gdk_pixbuf_get_width(buf); | 1717 *width = gdk_pixbuf_get_width(buf); |