Mercurial > pidgin.yaz
comparison src/protocols/oscar/ssi.c @ 4789:f1fde07ed951
[gaim-migrate @ 5109]
There is a slim chance this will fix the ssi crashes a few people have
been having.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 15 Mar 2003 18:23:38 +0000 |
parents | c0abcd675ca6 |
children | e737e3e08b4a |
comparison
equal
deleted
inserted
replaced
4788:9e8ae330fb28 | 4789:f1fde07ed951 |
---|---|
256 return 10; | 256 return 10; |
257 | 257 |
258 return 0; | 258 return 0; |
259 } | 259 } |
260 | 260 |
261 faim_export int aim_ssi_itemlist_valid(struct aim_ssi_item *list, struct aim_ssi_item *item) | |
262 { | |
263 struct aim_ssi_item *cur; | |
264 for (cur=list; cur; cur=cur->next) | |
265 if (cur == item) | |
266 return 1; | |
267 return 0; | |
268 } | |
269 | |
261 /** | 270 /** |
262 * Locally find an item given a group ID# and a buddy ID#. | 271 * Locally find an item given a group ID# and a buddy ID#. |
263 * | 272 * |
264 * @param list A pointer to the current list of items. | 273 * @param list A pointer to the current list of items. |
265 * @param gid The group ID# of the desired item. | 274 * @param gid The group ID# of the desired item. |
1416 */ | 1425 */ |
1417 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) { | 1426 for (cur=sess->ssi.pending; (cur && (cur->ack != 0xffff)); cur=cur->next) { |
1418 if (cur->item) { | 1427 if (cur->item) { |
1419 if (cur->ack) { | 1428 if (cur->ack) { |
1420 /* Our action was unsuccessful, so change the local list back to how it was */ | 1429 /* Our action was unsuccessful, so change the local list back to how it was */ |
1430 /* Make sure cur->item is still valid memory */ | |
1421 if (cur->action == AIM_CB_SSI_ADD) { | 1431 if (cur->action == AIM_CB_SSI_ADD) { |
1422 /* Remove the item from the local list */ | 1432 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { |
1423 if (cur->item->name) { | 1433 /* Remove the item from the local list */ |
1424 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); | 1434 if (cur->item->name) { |
1425 strcpy(cur->name, cur->item->name); | 1435 cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); |
1436 strcpy(cur->name, cur->item->name); | |
1437 } | |
1438 aim_ssi_itemlist_del(&sess->ssi.local, cur->item); | |
1426 } | 1439 } |
1427 aim_ssi_itemlist_del(&sess->ssi.local, cur->item); | |
1428 cur->item = NULL; | 1440 cur->item = NULL; |
1429 | 1441 |
1430 } else if (cur->action == AIM_CB_SSI_MOD) { | 1442 } else if (cur->action == AIM_CB_SSI_MOD) { |
1431 /* Replace the local item with the item from the official list */ | 1443 /* Replace the local item with the item from the official list */ |
1432 struct aim_ssi_item *cur1; | 1444 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { |
1433 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) { | 1445 struct aim_ssi_item *cur1; |
1434 free(cur->item->name); | 1446 if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) { |
1435 if (cur1->name) { | 1447 free(cur->item->name); |
1436 cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char)); | 1448 if (cur1->name) { |
1437 strcpy(cur->item->name, cur1->name); | 1449 cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char)); |
1438 } else | 1450 strcpy(cur->item->name, cur1->name); |
1439 cur->item->name = NULL; | 1451 } else |
1440 aim_freetlvchain(&cur->item->data); | 1452 cur->item->name = NULL; |
1441 cur->item->data = aim_tlvlist_copy(cur1->data); | 1453 aim_freetlvchain(&cur->item->data); |
1442 } | 1454 cur->item->data = aim_tlvlist_copy(cur1->data); |
1455 } | |
1456 } else | |
1457 cur->item = NULL; | |
1443 | 1458 |
1444 } else if (cur->action == AIM_CB_SSI_DEL) { | 1459 } else if (cur->action == AIM_CB_SSI_DEL) { |
1445 /* Add the item back into the local list */ | 1460 /* Add the item back into the local list */ |
1446 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); | 1461 if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { |
1462 aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); | |
1463 } else | |
1464 cur->item = NULL; | |
1447 } | 1465 } |
1448 | 1466 |
1449 } else { | 1467 } else { |
1450 /* Do the exact opposite */ | 1468 /* Do the exact opposite */ |
1451 if (cur->action == AIM_CB_SSI_ADD) { | 1469 if (cur->action == AIM_CB_SSI_ADD) { |