Bugs item #466752, was opened at 2001-10-01 01:10 You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=466752&group_id=5470 Category: Python Interpreter Core Group: None >Status: Closed >Resolution: Rejected Priority: 5 Submitted By: Nobody/Anonymous (nobody) >Assigned to: Guido van Rossum (gvanrossum) >Summary: "deref" error in _PyBuffer_FromObject Initial Comment: The "deref" code in function _PyBuffer_FromObject, file bufferobject.c is an error: ============== /* if the base object is another buffer, then "deref" it */ if ( PyBuffer_Check(base) ) base = ((PyBufferObject*)base)->b_base; return _PyBuffer_FromMemory(base, (char *)p + offset, size, readonly); ============== It is possible, that "deref"'ed base is NULL. In this case the new object will have no reference to any base object. Example (in C): ================ base_buffer=PyBuffer_New(100); derived_buffer=PyBuffer_FromObject(base_buffer,0,50); Py_DECREF(base_buffer); ================ And derived_buffer memory pointer points to nowhere. I think, the right code in _PyBuffer_FromObject would be: ============== /* if the base object is another buffer, then "deref" it */ if ( PyBuffer_Check(base) && (((PyBufferObject*)base)->b_base != NULL)) base = ((PyBufferObject*)base)->b_base; return _PyBuffer_FromMemory(base, (char *)p + offset, size, readonly); ============== Victor Sologoubov VSologoubov@ibs.ru ---------------------------------------------------------------------- >Comment By: Guido van Rossum (gvanrossum) Date: 2001-10-01 06:22 Message: Logged In: YES user_id=6380 Your example C code is simply wrong. This has been brought up before (is there an example on the web somewhere that does this???). Do not use the buffer API to allocate memory. ---------------------------------------------------------------------- You can respond by visiting: http://sourceforge.net/tracker/?func=detail&atid=105470&aid=466752&group_id=5470
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4