# HG changeset patch # User Daniel Atallah # Date 1226026163 0 # Node ID b4964c3f5f7c5e705b12a1b5ba7cf5b781878b49 # Parent f4cb55854e87bb162b4a3f218152557fb7a6c15b Fix a potential leak, thanks to "KuSh". Fixes #7465. diff -r f4cb55854e87 -r b4964c3f5f7c libpurple/protocols/simple/sipmsg.c --- a/libpurple/protocols/simple/sipmsg.c Thu Nov 06 22:35:03 2008 +0000 +++ b/libpurple/protocols/simple/sipmsg.c Fri Nov 07 02:49:23 2008 +0000 @@ -56,14 +56,17 @@ struct sipmsg *sipmsg_parse_header(const gchar *header) { struct sipmsg *msg = g_new0(struct sipmsg,1); - gchar **lines = g_strsplit(header,"\r\n",0); - gchar **parts; - gchar *dummy; - gchar *dummy2; - gchar *tmp; + gchar **parts, **lines = g_strsplit(header,"\r\n",0); + gchar *dummy, *dummy2, *tmp; const gchar *tmp2; - int i=1; - if(!lines[0]) return NULL; + int i = 1; + + if(!lines[0]) { + g_strfreev(lines); + g_free(msg); + return NULL; + } + parts = g_strsplit(lines[0], " ", 3); if(!parts[0] || !parts[1] || !parts[2]) { g_strfreev(parts); @@ -71,6 +74,7 @@ g_free(msg); return NULL; } + if(strstr(parts[0],"SIP")) { /* numeric response */ msg->method = g_strdup(parts[2]); msg->response = strtol(parts[1],NULL,10); @@ -80,6 +84,7 @@ msg->response = 0; } g_strfreev(parts); + for(i=1; lines[i] && strlen(lines[i])>2; i++) { parts = g_strsplit(lines[i], ":", 2); if(!parts[0] || !parts[1]) { @@ -104,9 +109,11 @@ g_strfreev(parts); } g_strfreev(lines); + tmp2 = sipmsg_find_header(msg, "Content-Length"); if (tmp2 != NULL) msg->bodylen = strtol(tmp2, NULL, 10); + if(msg->response) { tmp2 = sipmsg_find_header(msg, "CSeq"); if(!tmp2) { @@ -118,6 +125,7 @@ g_strfreev(parts); } } + return msg; }