Mercurial > pidgin
diff src/protocols/oscar/tlv.c @ 13652:a07dcc2c01bd
[gaim-migrate @ 16053]
Fix Coverity CID 42: Possible NULL pointer dereference when the server
does not give us a cookie in their reply to our login response. This
should never happen.
Fix Coverity CID 43 and 44: Possible NULL pointer dereference. Technically
not possible... but the code is cleaner and faster this way.
Fix Coverity CID 58: Fix a memleak of two small strings totaling about
10 bytes when parsing most incoming chat messages (not IM--just chat)
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Tue, 18 Apr 2006 04:03:18 +0000 |
| parents | 6519aeb66b31 |
| children |
line wrap: on
line diff
--- a/src/protocols/oscar/tlv.c Tue Apr 18 00:07:15 2006 +0000 +++ b/src/protocols/oscar/tlv.c Tue Apr 18 04:03:18 2006 +0000 @@ -810,6 +810,18 @@ return -1; } +char * +aim_tlv_getvalue_as_string(aim_tlv_t *tlv) +{ + char *ret; + + ret = malloc(tlv->length + 1); + memcpy(ret, tlv->value, tlv->length); + ret[tlv->length] = '\0'; + + return ret; +} + /** * Retrieve the data from the nth TLV in the given TLV chain as a string. * @@ -823,16 +835,11 @@ char *aim_tlv_getstr(aim_tlvlist_t *list, const guint16 type, const int nth) { aim_tlv_t *tlv; - char *ret; if (!(tlv = aim_tlv_gettlv(list, type, nth))) return NULL; - ret = malloc(tlv->length + 1); - memcpy(ret, tlv->value, tlv->length); - ret[tlv->length] = '\0'; - - return ret; + return aim_tlv_getvalue_as_string(tlv); } /**
