comparison src/protocols/yahoo/yahoo_packet.c @ 14142:89d043d547cc

[gaim-migrate @ 16784] Never allow Yahoo! to insert a NULL value into the outgoing packet hash. This fixes some random crashes when the packet gets sent, and yahoo_packet_length() is called, which eventually calls strlen(NULL), which crashes committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 16 Aug 2006 06:58:59 +0000
parents c070fdec12a3
children
comparison
equal deleted inserted replaced
14141:5f656a0a82b7 14142:89d043d547cc
38 return pkt; 38 return pkt;
39 } 39 }
40 40
41 void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value) 41 void yahoo_packet_hash_str(struct yahoo_packet *pkt, int key, const char *value)
42 { 42 {
43 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); 43 struct yahoo_pair *pair;
44
45 g_return_if_fail(value != NULL);
46
47 pair = g_new0(struct yahoo_pair, 1);
44 pair->key = key; 48 pair->key = key;
45 pair->value = g_strdup(value); 49 pair->value = g_strdup(value);
46 pkt->hash = g_slist_prepend(pkt->hash, pair); 50 pkt->hash = g_slist_prepend(pkt->hash, pair);
47 } 51 }
48 52
49 void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value) 53 void yahoo_packet_hash_int(struct yahoo_packet *pkt, int key, int value)
50 { 54 {
51 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1); 55 struct yahoo_pair *pair;
52 56
57 pair = g_new0(struct yahoo_pair, 1);
53 pair->key = key; 58 pair->key = key;
54 pair->value = g_strdup_printf("%d", value); 59 pair->value = g_strdup_printf("%d", value);
55 pkt->hash = g_slist_prepend(pkt->hash, pair); 60 pkt->hash = g_slist_prepend(pkt->hash, pair);
56 } 61 }
57 62