You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by Paul Haake <pn...@cornell.edu> on 2004/09/21 05:22:00 UTC

Bug in _filter_read?

I was trying to use output filtering in mod_python when I noticed that
the filter object's read() method often returns garbled data.  After
some debugging I discovered that the two lines below appear to be in
error.  As far as I can tell, buffer is supposed to point to where new
data will be written in result.ob_sval.  Thus it does not make sense to
reset buffer to the beginning of ob_sval after each bucket read.  In any
case, the fix seems to work.

diff -urN mod_python-3.1.3/src/filterobject.c
mod_python-3.1.3.new/src/filterobject.c
--- mod_python-3.1.3/src/filterobject.c	Mon Feb 16 14:47:27 2004
+++ mod_python-3.1.3.new/src/filterobject.c	Mon Sep 20 22:59:25 2004
@@ -258,8 +258,8 @@
         if (newline == 0 && len < 0 && bytes_read == bufsize) {
 
             _PyString_Resize(&result, bufsize + HUGE_STRING_LEN);
-            buffer = PyString_AS_STRING((PyStringObject *) result);
-            buffer += HUGE_STRING_LEN;
+            /* buffer = PyString_AS_STRING((PyStringObject *) result);
*/
+            /* buffer += HUGE_STRING_LEN; */
 
             bufsize += HUGE_STRING_LEN;
         }