# HG changeset patch # User Paul Aurich # Date 1259636062 0 # Node ID f6f35d5960e9eeb1709e22dabb7b37c9b8883aee # Parent 51d82a66e24762d4cc68e2c594179e096932bb2d Use g_strndup() for great justice. diff -r 51d82a66e247 -r f6f35d5960e9 libpurple/protocols/jabber/parser.c --- a/libpurple/protocols/jabber/parser.c Mon Nov 30 15:46:58 2009 +0000 +++ b/libpurple/protocols/jabber/parser.c Tue Dec 01 02:54:22 2009 +0000 @@ -47,9 +47,7 @@ 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,10 +86,7 @@ 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); - - memcpy(attrib, attributes[i+3], attrib_len); - attrib[attrib_len] = '\0'; + char *attrib = g_strndup((gchar *)attributes[i+3], attrib_len); txt = attrib; attrib = purple_unescape_html(txt); diff -r 51d82a66e247 -r f6f35d5960e9 libpurple/xmlnode.c --- a/libpurple/xmlnode.c Mon Nov 30 15:46:58 2009 +0000 +++ b/libpurple/xmlnode.c Tue Dec 01 02:54:22 2009 +0000 @@ -588,9 +588,7 @@ 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);