[Patches] [Patch #103753] zlib decompress; uncontrollable memory usage
noreply@sourceforge.net
noreply@sourceforge.net
Thu, 22 Feb 2001 03:42:57 -0800
Patch #103753 has been updated.
Project: python
Category: Modules
Status: Open
Submitted by: htrd
Assigned to : akuchling
Summary: zlib decompress; uncontrollable memory usage
Follow-Ups:
Date: 2001-Feb-22 03:42
By: htrd
Comment:
Waaah - that last comment should be 'cant' not 'can'
-------------------------------------------------------
Date: 2001-Feb-22 03:40
By: htrd
Comment:
We can reuse .unused_data without introducing an ambiguity. I will prepare
a patch that uses a new attribute .unconsumed_tail
-------------------------------------------------------
Date: 2001-Feb-21 11:32
By: akuchling
Comment:
Doesn't .unused_data serve much the same purpose, though?
So that even with a maximum size, .decompress() always returns a string,
and .unused_data would contain the unprocessed data.
-------------------------------------------------------
Date: 2001-Feb-21 06:00
By: htrd
Comment:
I did consider that....
An extra change that you didnt mention is the need for a different return
value. Currently .decompress() always returns a string. The new method in
my patch returns a tuple containing the same string, and an integer
specifying how many bytes were consumed from the input.
Overloading return values based on an optional parameter seems a little
hairy to me, but I would be happy to change the patch if that is your
preferred option.
I also considered (and rejected) the possibility of adding an optional
max-size argument to .decompress() as you suggest, but raising an exception
if this limit is exceeded. This avoids the need for an extra return value,
but looses out on flexibility.
-------------------------------------------------------
Date: 2001-Feb-20 18:48
By: akuchling
Comment:
Rather than introducing a new method, why not just add an optional maxlen
argument to .decompress(). I think the changes would be:
* add 'int maxlen=-1;'
* add "...|i" ... ,&maxlen to the argument parsing
* if maxlen != -1, length = maxlen else length = DEFAULTALLOC;
* Add '&& maxlen==-1' to the while loop. (Use the current CVS; I just
checked in a patch rearranging the zlib module a bit.)
Do you want to make those changes and resubmit the patch?
-------------------------------------------------------
-------------------------------------------------------
For more info, visit:
http://sourceforge.net/patch/?func=detailpatch&patch_id=103753&group_id=5470