Fixed crashing problems upon rejecting more than one friend request. (#172)

I think this is caused by uinf and uinf->user being a null pointer. Not really sure why that is, but this fixes the crash that would otherwise cause. I imagine it's because the user has never actually existed within the bitlbee user list and therefore doesn't need updating, but the real question is why it works for the first rejection but not the second.

I also slightly cleaned it up so uinf is defined before usage in either case, meaning there's only one definition statement.
This commit is contained in:
kat 2018-08-21 18:01:33 +01:00 committed by Artem Savkov
parent 967df38048
commit 3e7c694bf9
1 changed files with 7 additions and 6 deletions

View File

@ -193,6 +193,7 @@ static void discord_handle_relationship(struct im_connection *ic, json_value *ri
char *name = NULL;
json_value *uinfo = NULL;
bee_user_t *bu = NULL;
user_info *uinf = NULL;
json_value *tjs = json_o_get(rinfo, "type");
if (action == ACTION_CREATE) {
@ -209,7 +210,7 @@ static void discord_handle_relationship(struct im_connection *ic, json_value *ri
if (bu) {
bu->data = GINT_TO_POINTER(TRUE);
if (set_getbool(&ic->acc->set, "friendship_mode") == TRUE) {
user_info *uinf = get_user(dd, name, NULL, SEARCH_NAME);
uinf = get_user(dd, name, NULL, SEARCH_NAME);
imcb_buddy_status(ic, name, uinf->flags, NULL, NULL);
}
}
@ -218,17 +219,17 @@ static void discord_handle_relationship(struct im_connection *ic, json_value *ri
}
} else if (action == ACTION_DELETE) {
user_info *uinf = get_user(dd, json_o_str(rinfo, "id"), NULL, SEARCH_ID);
name = g_strdup(uinf->name);
bu = uinf->user;
if (bu) {
uinf = get_user(dd, json_o_str(rinfo, "id"), NULL, SEARCH_ID);
if (uinf && uinf->user) {
bu = uinf->user;
name = g_strdup(uinf->name);
bu->data = GINT_TO_POINTER(FALSE);
if (set_getbool(&ic->acc->set, "friendship_mode") == TRUE) {
imcb_buddy_status(ic, name, 0, NULL, NULL);
}
}
}
g_free(name);
}