Mercurial > pidgin
diff libpurple/protocols/simple/sipmsg.c @ 21024:61a87e02da29
Some constification, which also found and fixed some potential double-free
errors.
| author | Stu Tomlinson <stu@nosnilmot.com> |
|---|---|
| date | Sat, 27 Oct 2007 13:12:27 +0000 |
| parents | 44b4e8bd759b |
| children | 189abce087ab |
line wrap: on
line diff
--- a/libpurple/protocols/simple/sipmsg.c Fri Oct 26 13:22:49 2007 +0000 +++ b/libpurple/protocols/simple/sipmsg.c Sat Oct 27 13:12:27 2007 +0000 @@ -58,6 +58,7 @@ gchar *dummy; gchar *dummy2; gchar *tmp; + const gchar *tmp2; int i=1; if(!lines[0]) return NULL; parts = g_strsplit(lines[0], " ", 3); @@ -100,14 +101,16 @@ g_strfreev(parts); } g_strfreev(lines); - msg->bodylen = strtol(sipmsg_find_header(msg, "Content-Length"),NULL,10); + tmp2 = sipmsg_find_header(msg, "Content-Length"); + if (tmp2 != NULL) + msg->bodylen = strtol(tmp2, NULL, 10); if(msg->response) { - tmp = sipmsg_find_header(msg, "CSeq"); - if(!tmp) { + tmp2 = sipmsg_find_header(msg, "CSeq"); + if(!tmp2) { /* SHOULD NOT HAPPEN */ msg->method = 0; } else { - parts = g_strsplit(tmp, " ", 2); + parts = g_strsplit(tmp2, " ", 2); msg->method = g_strdup(parts[1]); g_strfreev(parts); } @@ -192,7 +195,7 @@ return; } -gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name) { +const gchar *sipmsg_find_header(struct sipmsg *msg, const gchar *name) { GSList *tmp; struct siphdrelement *elem; tmp = msg->headers;
