Mercurial > pidgin
diff libpurple/stringref.c @ 31807:b24babbae157
Bounds-check stringref copies (which are safe anyway)
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Wed, 17 Aug 2011 23:54:59 +0000 |
parents | d1b36a8c920a |
children |
line wrap: on
line diff
--- a/libpurple/stringref.c Wed Aug 17 22:00:37 2011 +0000 +++ b/libpurple/stringref.c Wed Aug 17 23:54:59 2011 +0000 @@ -65,12 +65,15 @@ PurpleStringref *purple_stringref_new(const char *value) { PurpleStringref *newref; + size_t len; if (value == NULL) return NULL; - newref = g_malloc(sizeof(PurpleStringref) + strlen(value)); - strcpy(newref->value, value); + len = strlen(value); + + newref = g_malloc(sizeof(PurpleStringref) + len); + g_strlcpy(newref->value, value, len); newref->ref = 1; return newref;