bug in the linkedlists macros where the prev node
authorMatt O'Gorman <mogorman@digium.com>
Wed, 22 Feb 2006 20:13:05 +0000 (20:13 +0000)
committerMatt O'Gorman <mogorman@digium.com>
Wed, 22 Feb 2006 20:13:05 +0000 (20:13 +0000)
was improperly managed when doing removals or insertions.
also solved issues with app_voicemail init. and reload
solves bug #6557

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@10766 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c
include/asterisk/linkedlists.h

index 6e19c95..7b9a37d 100644 (file)
@@ -5898,7 +5898,6 @@ static int load_config(void)
        }
        zones = NULL;
        zonesl = NULL;
        }
        zones = NULL;
        zonesl = NULL;
-       AST_LIST_HEAD_INIT(&users);
        memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
 
        if (cfg) {
        memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));
 
        if (cfg) {
index 49dd3a1..17d92c5 100644 (file)
@@ -298,9 +298,11 @@ struct {                                                           \
 #define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field) {                               \
        typeof((head)->first) __list_next;                                              \
        typeof((head)->first) __list_prev = NULL;                                       \
 #define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field) {                               \
        typeof((head)->first) __list_next;                                              \
        typeof((head)->first) __list_prev = NULL;                                       \
-       for ((var) = (head)->first,  __list_next = (var) ? (var)->field.next : NULL;    \
+       typeof((head)->first) __new_prev = NULL;                                        \
+       for ((var) = (head)->first, __new_prev = (var),                                 \
+             __list_next = (var) ? (var)->field.next : NULL;                           \
             (var);                                                                     \
             (var);                                                                     \
-            __list_prev = (var), (var) = __list_next,                                  \
+            __list_prev = __new_prev, (var) = __list_next,                             \
             __list_next = (var) ? (var)->field.next : NULL                             \
            )
 
             __list_next = (var) ? (var)->field.next : NULL                             \
            )
 
@@ -316,6 +318,7 @@ struct {                                                            \
   previous entry, if any).
  */
 #define AST_LIST_REMOVE_CURRENT(head, field)                                           \
   previous entry, if any).
  */
 #define AST_LIST_REMOVE_CURRENT(head, field)                                           \
+       __new_prev = __list_prev;                                                       \
        if (__list_prev)                                                                \
                __list_prev->field.next = __list_next;                                  \
        else                                                                            \
        if (__list_prev)                                                                \
                __list_prev->field.next = __list_next;                                  \
        else                                                                            \
@@ -340,7 +343,8 @@ struct {                                                            \
        } else {                                                        \
                (elm)->field.next = (head)->first;                      \
                (head)->first = (elm);                                  \
        } else {                                                        \
                (elm)->field.next = (head)->first;                      \
                (head)->first = (elm);                                  \
-       }                                                                               \
+       }                                                               \
+       __new_prev = (elm);                                             \
 } while (0)
 
 /*!
 } while (0)
 
 /*!