summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libzlib.tex
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2001-10-16 20:39:49 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2001-10-16 20:39:49 (GMT)
commit511e2cacc4aa67a83ed7c0ae34355407bdd13c57 (patch)
tree770b92726208bcae44db86fc8956348fe8d9a91e /Doc/lib/libzlib.tex
parent7a59445e3783fc842bc4fd0181b18d6798883a3e (diff)
downloadcpython-511e2cacc4aa67a83ed7c0ae34355407bdd13c57.zip
cpython-511e2cacc4aa67a83ed7c0ae34355407bdd13c57.tar.gz
cpython-511e2cacc4aa67a83ed7c0ae34355407bdd13c57.tar.bz2
[ #403753 ] zlib decompress; uncontrollable memory usage
Mostly by Toby Dickenson and Titus Brown. Add an optional argument to a decompression object's decompress() method. The argument specifies the maximum length of the return value. If the uncompressed data exceeds this length, the excess data is stored as the unconsumed_tail attribute. (Not to be confused with unused_data, which is a separate issue.) Difference from SF patch: Default value for unconsumed_tail is "" rather than None. It's simpler if the attribute is always a string.
Diffstat (limited to 'Doc/lib/libzlib.tex')
-rw-r--r--Doc/lib/libzlib.tex18
1 files changed, 16 insertions, 2 deletions
diff --git a/Doc/lib/libzlib.tex b/Doc/lib/libzlib.tex
index e384b1f..b9726d7 100644
--- a/Doc/lib/libzlib.tex
+++ b/Doc/lib/libzlib.tex
@@ -120,7 +120,7 @@ prevents compressing any more data. After calling
action is to delete the object.
\end{methoddesc}
-Decompression objects support the following methods, and a single attribute:
+Decompression objects support the following methods, and two attributes:
\begin{memberdesc}{unused_data}
A string which contains any unused data from the last string fed to
@@ -135,13 +135,27 @@ reading data and feeding it into a decompression object's
no longer the empty string.
\end{memberdesc}
-\begin{methoddesc}[Decompress]{decompress}{string}
+\begin{memberdesc}{unconsumed_tail}
+A string that contains any data that was not consumed by the last
+\method{decompress} call because it exceeded the limit for the
+uncompressed data buffer.
+\end{memberdesc}
+
+\begin{methoddesc}[Decompress]{decompress}{string}{\optional{max_length}}
Decompress \var{string}, returning a string containing the
uncompressed data corresponding to at least part of the data in
\var{string}. This data should be concatenated to the output produced
by any preceding calls to the
\method{decompress()} method. Some of the input data may be preserved
in internal buffers for later processing.
+
+If the optional parameter \var{max_length} is supplied then the return value
+will be no longer than \var{max_length}. This may mean that not all of the
+compressed input can be processed; and unconsumed data will be stored
+in the attribute \member{unconsumed_tail}. This string must be passed
+to a subsequent call to \method{decompress()} if decompression is to
+continue. If \var{max_length} is not supplied then the whole input is
+decompressed, and \member{unconsumed_tail} is an empty string.
\end{methoddesc}
\begin{methoddesc}[Decompress]{flush}{}