# HG changeset patch # User Mark Doliner # Date 1047752618 0 # Node ID f1fde07ed951bab35aa35372d2526c7ae9f261d9 # Parent 9e8ae330fb28decf39be98366b6fd0bda554324c [gaim-migrate @ 5109] There is a slim chance this will fix the ssi crashes a few people have been having. committer: Tailor Script diff -r 9e8ae330fb28 -r f1fde07ed951 src/protocols/oscar/ssi.c --- a/src/protocols/oscar/ssi.c Sat Mar 15 17:46:10 2003 +0000 +++ b/src/protocols/oscar/ssi.c Sat Mar 15 18:23:38 2003 +0000 @@ -258,6 +258,15 @@ return 0; } +faim_export int aim_ssi_itemlist_valid(struct aim_ssi_item *list, struct aim_ssi_item *item) +{ + struct aim_ssi_item *cur; + for (cur=list; cur; cur=cur->next) + if (cur == item) + return 1; + return 0; +} + /** * Locally find an item given a group ID# and a buddy ID#. * @@ -1418,32 +1427,41 @@ if (cur->item) { if (cur->ack) { /* Our action was unsuccessful, so change the local list back to how it was */ + /* Make sure cur->item is still valid memory */ if (cur->action == AIM_CB_SSI_ADD) { - /* Remove the item from the local list */ - if (cur->item->name) { - cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); - strcpy(cur->name, cur->item->name); + if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { + /* Remove the item from the local list */ + if (cur->item->name) { + cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char)); + strcpy(cur->name, cur->item->name); + } + aim_ssi_itemlist_del(&sess->ssi.local, cur->item); } - aim_ssi_itemlist_del(&sess->ssi.local, cur->item); cur->item = NULL; } else if (cur->action == AIM_CB_SSI_MOD) { /* Replace the local item with the item from the official list */ - struct aim_ssi_item *cur1; - if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) { - free(cur->item->name); - if (cur1->name) { - cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char)); - strcpy(cur->item->name, cur1->name); - } else - cur->item->name = NULL; - aim_freetlvchain(&cur->item->data); - cur->item->data = aim_tlvlist_copy(cur1->data); - } + if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { + struct aim_ssi_item *cur1; + if ((cur1 = aim_ssi_itemlist_find(sess->ssi.official, cur->item->gid, cur->item->bid))) { + free(cur->item->name); + if (cur1->name) { + cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char)); + strcpy(cur->item->name, cur1->name); + } else + cur->item->name = NULL; + aim_freetlvchain(&cur->item->data); + cur->item->data = aim_tlvlist_copy(cur1->data); + } + } else + cur->item = NULL; } else if (cur->action == AIM_CB_SSI_DEL) { /* Add the item back into the local list */ - aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); + if (aim_ssi_itemlist_valid(sess->ssi.local, cur->item)) { + aim_ssi_itemlist_add(&sess->ssi.local, cur->item->name, cur->item->gid, cur->item->bid, cur->item->type, cur->item->data); + } else + cur->item = NULL; } } else {