Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/caps.c @ 26850:966d2f2f86c8
Don't crash when the caps cb is NULL and don't corrupt jabber_identities
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 01 May 2009 18:59:31 +0000 |
parents | b1f8cebaab17 |
children | e72df47d41fe |
comparison
equal
deleted
inserted
replaced
26849:47d03538ee3f | 26850:966d2f2f86c8 |
---|---|
404 } | 404 } |
405 | 405 |
406 static void | 406 static void |
407 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata) | 407 jabber_caps_get_info_complete(jabber_caps_cbplususerdata *userdata) |
408 { | 408 { |
409 userdata->cb(userdata->info, userdata->exts, userdata->cb_data); | 409 if (userdata->cb) { |
410 userdata->info = NULL; | 410 userdata->cb(userdata->info, userdata->exts, userdata->cb_data); |
411 userdata->exts = NULL; | 411 userdata->info = NULL; |
412 userdata->exts = NULL; | |
413 } | |
412 | 414 |
413 if (userdata->ref != 1) | 415 if (userdata->ref != 1) |
414 purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n", | 416 purple_debug_warning("jabber", "Lost a reference to caps cbdata: %d\n", |
415 userdata->ref); | 417 userdata->ref); |
416 } | 418 } |
560 key.hash = (char *)hash; | 562 key.hash = (char *)hash; |
561 | 563 |
562 info = g_hash_table_lookup(capstable, &key); | 564 info = g_hash_table_lookup(capstable, &key); |
563 if (info && hash) { | 565 if (info && hash) { |
564 /* v1.5 - We already have all the information we care about */ | 566 /* v1.5 - We already have all the information we care about */ |
565 cb(info, NULL, user_data); | 567 if (cb) |
568 cb(info, NULL, user_data); | |
566 return; | 569 return; |
567 } | 570 } |
568 | 571 |
569 userdata = g_new0(jabber_caps_cbplususerdata, 1); | 572 userdata = g_new0(jabber_caps_cbplususerdata, 1); |
570 /* This ref is given to fetching the basic node#ver info if we need it | 573 /* This ref is given to fetching the basic node#ver info if we need it |
894 } | 897 } |
895 } | 898 } |
896 } | 899 } |
897 | 900 |
898 info.features = features; | 901 info.features = features; |
899 info.identities = jabber_identities; | 902 info.identities = g_list_copy(jabber_identities); |
900 info.forms = NULL; | 903 info.forms = NULL; |
901 | 904 |
902 g_free(js->caps_hash); | 905 g_free(js->caps_hash); |
903 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1"); | 906 js->caps_hash = jabber_caps_calculate_hash(&info, "sha1"); |
907 g_list_free(info.identities); | |
904 g_list_free(features); | 908 g_list_free(features); |
905 } | 909 } |
906 | 910 |
907 const gchar* jabber_caps_get_own_hash(JabberStream *js) | 911 const gchar* jabber_caps_get_own_hash(JabberStream *js) |
908 { | 912 { |