[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Ayttm-commits] CVS: ayttm/modules/msn2 msn.C,1.18,1.19
From: |
Colin Leroy <address@hidden> |
Subject: |
[Ayttm-commits] CVS: ayttm/modules/msn2 msn.C,1.18,1.19 |
Date: |
Fri, 10 Jan 2003 03:17:22 -0500 |
Update of /cvsroot/ayttm/ayttm/modules/msn2
In directory subversions:/tmp/cvs-serv17648/modules/msn2
Modified Files:
msn.C
Log Message:
fix segfaults in chatroom
Index: msn.C
===================================================================
RCS file: /cvsroot/ayttm/ayttm/modules/msn2/msn.C,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- msn.C 9 Jan 2003 10:14:08 -0000 1.18
+++ msn.C 10 Jan 2003 08:17:20 -0000 1.19
@@ -26,6 +26,7 @@
#ifdef __MINGW32__
#define __IN_PLUGIN__
#endif
+#include <glib.h>
#include "intl.h"
#include <stdio.h>
#include <string.h>
@@ -582,7 +583,7 @@
if(!account->connected)
return;
eb_debug(DBG_MOD, "Logging out\n");
- for (l = msn_contacts; l; l = l->next) {
+ for (l = msn_contacts; l != NULL && l->data != NULL; l = l->next) {
eb_account * ea = (eb_account *)find_account_by_handle((char
*)l->data, SERVICE_INFO.protocol_id);
eb_msn_account_data * mad = (eb_msn_account_data
*)ea->protocol_account_data;
mad->status=MSN_OFFLINE;
@@ -648,9 +649,8 @@
char buf[1024];
snprintf(buf, 1024, "Warning - your last message was too long for
the MSN service. The last %d characters were not sent.", strlen(mess)-2000);
do_error_dialog(buf, "MSN: Message truncated");
- mess[2000]='\0';
}
- msg->body = realloc_cpp(StrToUtf8(mess));
+ msg->body = g_strndup(StrToUtf8(mess), 1998);
eb_msn_local_account_data * mlad;
mlad = (eb_msn_local_account_data *)from->protocol_local_account_data;
@@ -1094,7 +1094,7 @@
{
message * msg=new message;
msg->header=NULL;
- msg->body=realloc_cpp(StrToUtf8(mess));
+ msg->body=g_strndup(StrToUtf8(mess), 1998);
msg->font=NULL;
msg->content=strdup("text/plain; charset=UTF-8");
@@ -1102,11 +1102,11 @@
msnconn * conn=(msnconn *)room->protocol_local_chat_room_data;
msn_send_IM(conn, NULL, msg); // simple, isn't it?
-
+ g_free(msg->body);
+ msg->body=NULL;
delete msg;
eb_chat_room_show_message(room, room->chat_room_account->handle, mess);
- msg->body=NULL;
}
void eb_msn_join_chat_room( eb_chat_room * room )
@@ -1604,12 +1604,14 @@
eb_msn_local_account_data *mlad;
/* UNUSED char *newHandle = NULL */
char *local_account_name=NULL;
+ char *lmess;
eb_local_account *ela=NULL;
/* handle utf8 */
if (msg->content != NULL && !strcmp(msg->content, "text/plain;
charset=UTF-8"))
- msg->body = Utf8ToStr (msg->body);
-
+ lmess = strdup(Utf8ToStr(msg->body));
+ else
+ lmess = strdup(msg->body);
/* The username element is always valid, even if it's not an SB */
local_account_name=((authdata_SB *)conn->auth)->username;
ela = find_local_account_by_handle(local_account_name,
SERVICE_INFO.protocol_id);
@@ -1642,15 +1644,16 @@
if(ecr!=NULL)
{
if(sender->account_contact->nick)
- eb_chat_room_show_message(ecr, sender->account_contact->nick,
msg->body);
+ eb_chat_room_show_message(ecr, sender->account_contact->nick, lmess);
else
- eb_chat_room_show_message(ecr, username, msg->body);
+ eb_chat_room_show_message(ecr, username, lmess);
+ g_free(lmess);
return;
}
//FIXME: There has to be a cleaner way to do this
- if(!strcmp(username, "Hotmail") && (!msg->body || !msg->body[0]))
+ if(!strcmp(username, "Hotmail") && (!lmess || !lmess[0]))
{
mlad = (eb_msn_local_account_data *)ela->protocol_local_account_data;
eb_debug(DBG_MOD, "Setting our state to: %s\n",
msn_state_strings[mlad->status]);
@@ -1658,9 +1661,10 @@
return;
}
- eb_parse_incomming_message(ela, sender, &SERVICE_INFO, msg->body);
+ eb_parse_incomming_message(ela, sender, &SERVICE_INFO, lmess);
if(sender != NULL)
eb_update_status(sender, NULL);
+ g_free(lmess);
}
void ext_IM_failed(msnconn * conn)
@@ -1704,13 +1708,6 @@
do_error_dialog(buf, "New MSN mail");
- /*
- msg->header=NULL;
- msg->body=msn_create_mail_initial_notify (unread_ibc, unread_fold);
- msg->font=NULL;
- msg->content=strdup("text/plain");
- ext_got_IM(conn, "Hotmail", "Hotmail", msg);
- */
}
void ext_new_mail_arrived(msnconn * conn, char * from, char * subject) {
@@ -1968,7 +1965,6 @@
if(msg->font==NULL) { return; }
retval = g_strdup (msg->body);
- delete msg->body;
if (msg->italic)
retval = g_strdup_printf ("<i>%s</i>", retval);
if (msg->bold)
@@ -1981,8 +1977,8 @@
* PF: ? (ditto)
*/
- delete msg->body;
- msg->body=g_realloc_cpp(retval);
+ g_free(msg->body);
+ msg->body=strdup(retval);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Ayttm-commits] CVS: ayttm/modules/msn2 msn.C,1.18,1.19,
Colin Leroy <address@hidden> <=
- Prev by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.67,1.68 configure.in,1.66,1.67
- Next by Date:
[Ayttm-commits] CVS: ayttm ChangeLog,1.68,1.69 configure.in,1.67,1.68
- Previous by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.67,1.68 configure.in,1.66,1.67
- Next by thread:
[Ayttm-commits] CVS: ayttm ChangeLog,1.68,1.69 configure.in,1.67,1.68
- Index(es):