]> granicus.if.org Git - python/commitdiff
Fix for Bug #216405:
authorThomas Heller <theller@ctypes.org>
Fri, 19 Oct 2001 13:49:35 +0000 (13:49 +0000)
committerThomas Heller <theller@ctypes.org>
Fri, 19 Oct 2001 13:49:35 +0000 (13:49 +0000)
use the correct base for a buffer object in _PyBuffer_FromObject.

Objects/bufferobject.c

index 242261f7187634366a47381b498dc5e14dda8da4..57d031cade56824b0a51304ce9541b73f063aa83 100644 (file)
@@ -73,11 +73,13 @@ _PyBuffer_FromObject(PyObject *base, int offset, int size,
                offset = count;
        if ( offset + size > count )
                size = count - offset;
-
-       /* if the base object is another buffer, then "deref" it */
-       if ( PyBuffer_Check(base) )
+       
+       /* if the base object is another buffer, then "deref" it,
+        * except if the base of the other buffer is NULL
+        */
+       if ( PyBuffer_Check(base) && (((PyBufferObject *)base)->b_base) )
                base = ((PyBufferObject *)base)->b_base;
-
+       
        return _PyBuffer_FromMemory(base, (char *)p + offset, size, readonly);
 }