[ python-Bugs-950274 ] buffer() can point to freed memory

SourceForge.net noreply at sourceforge.net
Sat May 8 00:02:30 EDT 2004


Bugs item #950274, was opened at 2004-05-07 21:02
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950274&group_id=5470

Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: L. Peter Deutsch (lpd)
Assigned to: Nobody/Anonymous (nobody)
Summary: buffer() can point to freed memory

Initial Comment:
This is related to the issue in bug 216405, but
different enough that I think it needs consideration.

Sample code:

import array
t = array.array('b', 100 * 'x')
u = buffer(t, 0, 100)
del t[:]
print u[:]

You'll probably get something that is *not* 100 x's,
because the buffer will point to (partly) deallocated
storage.

This problem can arise with any buffer if the object it
references can change length.  Buffers currently refuse
to reference lists, but they don't refuse arrays.

Frankly, I don't know what to recommend here. I was
surprised when I found out that arrays can change
length: my first suggestion is to remove this
capability. If this isn't acceptable, I don't know what
to suggest next.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=950274&group_id=5470



More information about the Python-bugs-list mailing list