BUGFIX notification management fixed
diff --git a/src/notification-server.c b/src/notification-server.c
index 588594b..eaa3d9f 100644
--- a/src/notification-server.c
+++ b/src/notification-server.c
@@ -560,8 +560,8 @@
 
         if (ls->notif_count) {
             DEBUG("notification: POP notifications for session");
-            for (i = 0; i < ls->notif_count; ++i) {
-                notif = ls->notifications + i;
+            for (i = ls->notif_count; i; --i) {
+                notif = ls->notifications + i - 1;
 
                 n = 0;
                 pthread_mutex_lock(&json_lock);
@@ -586,6 +586,10 @@
                 pthread_mutex_unlock(&json_lock);
                 free(notif->content);
             }
+            ls->notif_count = 0;
+            free(ls->notifications);
+            ls->notifications = NULL;
+
             DEBUG("notification: POP notifications done");
         }