pidgin/pidgin

Fix an issue scanbuild found by making the function readable
release-2.x.y
2021-06-01, Gary Kramlich
b6f7ee1f368a
Parents 5c79001c7e86
Children f2cec5958ed7
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/
--- 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;
+ }
}
}