# HG changeset patch # User Gary Kramlich # Date 1622586993 18000 # Node ID b6f7ee1f368a4f1c9dc67f49b486d385f5d98074 # Parent 5c79001c7e86e518ef646caa224ec924a71f57b3 Fix an issue scanbuild found by making the function readable Testing Done: Ran scanbuild and verified the error was fixed. Reviewed at https://reviews.imfreedom.org/r/696/ diff -r 5c79001c7e86 -r b6f7ee1f368a libpurple/notify.c --- a/libpurple/notify.c Tue Jun 01 17:36:18 2021 -0500 +++ b/libpurple/notify.c Tue Jun 01 17:36:33 2021 -0500 @@ -746,17 +746,21 @@ void purple_notify_close_with_handle(void *handle) { - GList *l, *prev = NULL; + GList *l; PurpleNotifyUiOps *ops; g_return_if_fail(handle != NULL); ops = purple_notify_get_ui_ops(); - for (l = handles; l != NULL; l = prev ? prev->next : handles) { - PurpleNotifyInfo *info = l->data; + l = handles; + while(l != NULL) { + PurpleNotifyInfo *info = (PurpleNotifyInfo *)l->data; - if (info->handle == handle) { + if(info != NULL && info->handle == handle) { + /* Move to the next item before we remove our current item. */ + l = l->next; + handles = g_list_remove(handles, info); if (ops != NULL && ops->close_notify != NULL) @@ -766,8 +770,9 @@ info->cb(info->cb_user_data); g_free(info); - } else - prev = l; + } else { + l = l->next; + } } }