Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 31806:49d6ee09c74d | 31807:b24babbae157 |
|---|---|
| 63 static gboolean gs_idle_cb(gpointer data); | 63 static gboolean gs_idle_cb(gpointer data); |
| 64 | 64 |
| 65 PurpleStringref *purple_stringref_new(const char *value) | 65 PurpleStringref *purple_stringref_new(const char *value) |
| 66 { | 66 { |
| 67 PurpleStringref *newref; | 67 PurpleStringref *newref; |
| 68 size_t len; | |
| 68 | 69 |
| 69 if (value == NULL) | 70 if (value == NULL) |
| 70 return NULL; | 71 return NULL; |
| 71 | 72 |
| 72 newref = g_malloc(sizeof(PurpleStringref) + strlen(value)); | 73 len = strlen(value); |
| 73 strcpy(newref->value, value); | 74 |
| 75 newref = g_malloc(sizeof(PurpleStringref) + len); | |
| 76 g_strlcpy(newref->value, value, len); | |
| 74 newref->ref = 1; | 77 newref->ref = 1; |
| 75 | 78 |
| 76 return newref; | 79 return newref; |
| 77 } | 80 } |
| 78 | 81 |
