pidgin: d5e860ee: Use g_strndup() for great justice.
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Mon Nov 30 23:25:53 EST 2009
-----------------------------------------------------------------
Revision: d5e860ee48c6c12f5962c772e68a5ad820ccd329
Ancestor: 00b667d9b2d5b9909693bc8c364232732b8fad0f
Author: darkrain42 at pidgin.im
Date: 2009-12-01T02:54:22
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/d5e860ee48c6c12f5962c772e68a5ad820ccd329
Modified files:
libpurple/protocols/jabber/parser.c libpurple/xmlnode.c
ChangeLog:
Use g_strndup() for great justice.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/parser.c 8e8389c03f6a29eb750a930ee4f14ddbee20f6cd
+++ libpurple/protocols/jabber/parser.c a86d436ab9930c524e1e7e6bdccb145a176a65e8
@@ -47,9 +47,7 @@ jabber_parser_element_start_libxml(void
js->protocol_version = JABBER_PROTO_0_9;
for(i=0; i < nb_attributes * 5; i += 5) {
int attrib_len = attributes[i+4] - attributes[i+3];
- char *attrib = g_malloc(attrib_len + 1);
- memcpy(attrib, attributes[i+3], attrib_len);
- attrib[attrib_len] = '\0';
+ char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len);
if(!xmlStrcmp(attributes[i], (xmlChar*) "version")
&& !strcmp(attrib, "1.0")) {
@@ -88,11 +86,8 @@ jabber_parser_element_start_libxml(void
const char *attrib_ns = (const char *)attributes[i+2];
char *txt;
int attrib_len = attributes[i+4] - attributes[i+3];
- char *attrib = g_malloc(attrib_len + 1);
+ char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len);
- memcpy(attrib, attributes[i+3], attrib_len);
- attrib[attrib_len] = '\0';
-
txt = attrib;
attrib = purple_unescape_html(txt);
g_free(txt);
============================================================
--- libpurple/xmlnode.c 807040ba848b14a6ce37b38355aa9cd85925d435
+++ libpurple/xmlnode.c 48c909f1ec8254acd3e2f81b93e0d71021113784
@@ -588,9 +588,7 @@ xmlnode_parser_element_start_libxml(void
const char *prefix = (const char *)attributes[i+1];
char *txt;
int attrib_len = attributes[i+4] - attributes[i+3];
- char *attrib = g_malloc(attrib_len + 1);
- memcpy(attrib, attributes[i+3], attrib_len);
- attrib[attrib_len] = '\0';
+ char *attrib = g_strndup(attributes[i+3], attrib_len);
txt = attrib;
attrib = purple_unescape_html(txt);
g_free(txt);
More information about the Commits
mailing list