Mercurial > cpython-lru_cache-weakref
diff Objects/bufferobject.c @ 20565:6f9902ace18d legacy-trunk
Fix for Bug #216405:
use the correct base for a buffer object in _PyBuffer_FromObject.
| author | Thomas Heller <theller@ctypes.org> |
|---|---|
| date | Fri, 19 Oct 2001 13:49:35 +0000 |
| parents | 0e70df98424e |
| children | f3a416b178c4 |
line wrap: on
line diff
--- a/Objects/bufferobject.c Fri Oct 19 12:40:40 2001 +0000 +++ b/Objects/bufferobject.c Fri Oct 19 13:49:35 2001 +0000 @@ -73,11 +73,13 @@ 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); }
