[Zope-Checkins] SVN: Zope/trunk/ - Collector #1406: fixed segmentation fault by acquisition

Andreas Jung andreas at andreas-jung.com
Mon Jul 5 10:48:15 EDT 2004


Log message for revision 26100:

     - Collector #1406: fixed segmentation fault by acquisition




-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt	2004-07-04 00:26:23 UTC (rev 26099)
+++ Zope/trunk/doc/CHANGES.txt	2004-07-05 14:48:15 UTC (rev 26100)
@@ -127,6 +127,8 @@
 
     Bugs fixed
 
+     - Collector #1406: fixed segmentation fault by acquisition
+
      - Collector #1392: ExternalMethod ignored management_page_charset
 
      - unrestrictedTraverse() refactored to remove hasattr calls (which mask

Modified: Zope/trunk/lib/python/Acquisition/_Acquisition.c
===================================================================
--- Zope/trunk/lib/python/Acquisition/_Acquisition.c	2004-07-04 00:26:23 UTC (rev 26099)
+++ Zope/trunk/lib/python/Acquisition/_Acquisition.c	2004-07-05 14:48:15 UTC (rev 26100)
@@ -466,7 +466,7 @@
 	    ASSIGN(r,PyECMethod_New(r,OBJECT(self)));
 	  else if (has__of__(r)) ASSIGN(r,__of__(r,OBJECT(self)));
 
-	  if (filter)
+	  if (r && filter)
 	    switch(apply_filter(filter,OBJECT(self),oname,r,extra,orig))
 	      {
 	      case -1: return NULL;

Modified: Zope/trunk/lib/python/Acquisition/tests.py
===================================================================
--- Zope/trunk/lib/python/Acquisition/tests.py	2004-07-04 00:26:23 UTC (rev 26099)
+++ Zope/trunk/lib/python/Acquisition/tests.py	2004-07-05 14:48:15 UTC (rev 26100)
@@ -534,6 +534,33 @@
 
     """
 
+def test__of__exception():
+    """
+    Wrapper_findattr did't check for an exception in a user defined
+    __of__ method before passing the result to the filter. In this
+    case the 'value' argument of the filter was NULL, which caused
+    a segfault when being accessed.
+
+    >>> class UserError(Exception):
+    ...     pass
+    ...
+    >>> class X(Acquisition.Implicit):
+    ...     def __of__(self, parent):
+    ...         if Acquisition.aq_base(parent) is not parent:
+    ...             raise UserError, 'ack'
+    ...         return X.inheritedAttribute('__of__')(self, parent)
+    ...
+    >>> a = I('a')
+    >>> a.b = I('b')
+    >>> a.b.x = X('x')
+    >>> Acquisition.aq_acquire(a.b, 'x',
+    ...     lambda self, object, name, value, extra: repr(value))
+    Traceback (most recent call last):
+    ...
+    UserError: ack
+
+    """
+
 def test_muliple():
     r"""
     >>> a = I('a')



More information about the Zope-Checkins mailing list