[asterisk-commits] twilson: trunk r328718 - in /trunk: ./ include/asterisk/ tests/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 18 21:01:00 CDT 2011


Author: twilson
Date: Mon Jul 18 21:00:56 2011
New Revision: 328718

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=328718
Log:
Merged revisions 328717 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.10

................
  r328717 | twilson | 2011-07-18 20:55:32 -0500 (Mon, 18 Jul 2011) | 14 lines
  
  Merged revisions 328716 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.8
  
  ........
    r328716 | twilson | 2011-07-18 20:35:53 -0500 (Mon, 18 Jul 2011) | 7 lines
    
    Make AST_LIST_REMOVE safer
    
    AST_LIST_REMOVE shouldn't modify the element passed in if it isn't found. This
    commit also adds linked list unit tests.
    
    Review: https://reviewboard.asterisk.org/r/1321/
  ........
................

Added:
    trunk/tests/test_linkedlists.c
      - copied unchanged from r328717, branches/1.10/tests/test_linkedlists.c
Modified:
    trunk/   (props changed)
    trunk/include/asterisk/linkedlists.h

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-1.10-merged (original)
+++ branch-1.10-merged Mon Jul 18 21:00:56 2011
@@ -1,1 +1,1 @@
-/branches/1.10:1-328075,328120,328162,328207,328247,328317,328329,328428-328429,328448,328451,328541,328609,328611,328664
+/branches/1.10:1-328075,328120,328162,328207,328247,328317,328329,328428-328429,328448,328451,328541,328609,328611,328664,328717

Modified: trunk/include/asterisk/linkedlists.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/linkedlists.h?view=diff&rev=328718&r1=328717&r2=328718
==============================================================================
--- trunk/include/asterisk/linkedlists.h (original)
+++ trunk/include/asterisk/linkedlists.h Mon Jul 18 21:00:56 2011
@@ -838,7 +838,10 @@
  */
 #define AST_LIST_REMOVE(head, elm, field) ({			        \
 	__typeof(elm) __res = NULL; \
-	if ((head)->first == (elm)) {					\
+	__typeof(elm) __tmp = elm; \
+	if (!__tmp) { \
+		__res = NULL; \
+	} else if ((head)->first == (elm)) {					\
 		__res = (head)->first;                      \
 		(head)->first = (elm)->field.next;			\
 		if ((head)->last == (elm))			\
@@ -854,7 +857,9 @@
 				(head)->last = curelm;				\
 		} \
 	}								\
-	(elm)->field.next = NULL;                                       \
+	if (__res) { \
+		(__res)->field.next = NULL; \
+	} \
 	(__res); \
 })
 




More information about the asterisk-commits mailing list