comparison libpurple/protocols/yahoo/libymsg.c @ 31082:86598f5d7ebd

Yahoo: Fix a crash that happens when the PurpleAccount disconnects after purple_network_listen() is called in yahoo_send_p2p_pkt(), but before the callback for purple_network_listen() is called. This solution isn't perfect-- it will almost certainly fall flat on its face if yahoo_send_p2p_packet() is called twice in a row--but doesn't make matters worse. Fixes #12432. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author hanzz@soc.pidgin.im
date Thu, 30 Dec 2010 01:22:52 +0000
parents 943fce8ef142
children a8cc50c2279f
comparison
equal deleted inserted replaced
31081:e023b0378887 31082:86598f5d7ebd
2671 YahooData *yd; 2671 YahooData *yd;
2672 2672
2673 if(!(p2p_data = data)) 2673 if(!(p2p_data = data))
2674 return ; 2674 return ;
2675 2675
2676 yd = p2p_data->gc->proto_data;
2677 yd->listen_data = NULL;
2678
2676 if(listenfd == -1) { 2679 if(listenfd == -1) {
2677 purple_debug_warning("yahoo","p2p: error starting p2p server\n"); 2680 purple_debug_warning("yahoo","p2p: error starting p2p server\n");
2678 yahoo_p2p_disconnect_destroy_data(data); 2681 yahoo_p2p_disconnect_destroy_data(data);
2679 return; 2682 return;
2680 } 2683 }
2681
2682 yd = p2p_data->gc->proto_data;
2683 2684
2684 /* Add an Input Read event to the file descriptor */ 2685 /* Add an Input Read event to the file descriptor */
2685 yd->yahoo_local_p2p_server_fd = listenfd; 2686 yd->yahoo_local_p2p_server_fd = listenfd;
2686 yd->yahoo_p2p_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_server_send_connected_cb,data); 2687 yd->yahoo_p2p_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_server_send_connected_cb,data);
2687 2688
2757 p2p_data->host_username = g_strdup(who); 2758 p2p_data->host_username = g_strdup(who);
2758 p2p_data->val_13 = val_13; 2759 p2p_data->val_13 = val_13;
2759 p2p_data->connection_type = YAHOO_P2P_WE_ARE_SERVER; 2760 p2p_data->connection_type = YAHOO_P2P_WE_ARE_SERVER;
2760 p2p_data->source = -1; 2761 p2p_data->source = -1;
2761 2762
2762 /* FIXME: Shouldn't this deal with the PurpleNetworkListenData* */ 2763 /* FIXME: If the port is already used, purple_network_listener returns NULL and old listener won't be canceled
2763 purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data); 2764 * in yahoo_close function. */
2765 if (yd->listen_data)
2766 purple_debug_warning("yahoo","p2p: Failed to create p2p server - server already exists\n");
2767 else {
2768 yd->listen_data = purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
2769 if (yd->listen_data == NULL)
2770 purple_debug_warning("yahoo","p2p: Failed to created p2p server\n");
2771 }
2764 2772
2765 g_free(base64_ip); 2773 g_free(base64_ip);
2766 } 2774 }
2767 2775
2768 /* function called when connection to p2p host is setup */ 2776 /* function called when connection to p2p host is setup */
3782 purple_proxy_connect_cancel(yd->buddy_icon_connect_data); 3790 purple_proxy_connect_cancel(yd->buddy_icon_connect_data);
3783 if (yd->picture_upload_todo) 3791 if (yd->picture_upload_todo)
3784 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); 3792 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo);
3785 if (yd->ycht) 3793 if (yd->ycht)
3786 ycht_connection_close(yd->ycht); 3794 ycht_connection_close(yd->ycht);
3795 if (yd->listen_data != NULL)
3796 purple_network_listen_cancel(yd->listen_data);
3787 3797
3788 g_free(yd->pending_chat_room); 3798 g_free(yd->pending_chat_room);
3789 g_free(yd->pending_chat_id); 3799 g_free(yd->pending_chat_id);
3790 g_free(yd->pending_chat_topic); 3800 g_free(yd->pending_chat_topic);
3791 g_free(yd->pending_chat_goto); 3801 g_free(yd->pending_chat_goto);