presence: check for null head when reordering returned presentity list
authorDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 8 May 2020 19:37:52 +0000 (21:37 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Fri, 8 May 2020 19:37:52 +0000 (21:37 +0200)
src/modules/presence/hash.c

index 9c81b7b..c313b01 100644 (file)
@@ -1296,7 +1296,9 @@ ps_presentity_t *ps_ptable_search(ps_presentity_t *ptm, int mmode, int rmode)
                                        ptl->prev = NULL;
                                }
                                ptd->next = pte;
-                               pte->prev = ptd;
+                               if(pte) {
+                                       pte->prev = ptd;
+                               }
                                pte = ptd;
                        } else {
                                if(ptd->prev) {
@@ -1307,7 +1309,9 @@ ps_presentity_t *ps_ptable_search(ps_presentity_t *ptm, int mmode, int rmode)
                                }
                                ptd->next = pte;
                                ptd->prev = NULL;
-                               pte->prev = ptd;
+                               if(pte) {
+                                       pte->prev = ptd;
+                               }
                                pte = ptd;
                        }
                }
@@ -1394,4 +1398,4 @@ ps_presentity_t *ps_ptable_get_expired(int eval)
        }
 
        return ptl;
-}
\ No newline at end of file
+}