summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham.Dumpleton <devnull@localhost>2009-03-07 01:00:17 +0000
committerGraham.Dumpleton <devnull@localhost>2009-03-07 01:00:17 +0000
commitc17aea2e76533cf0bfbad57c32741a26416dc187 (patch)
tree14933439374928f697b717edd9b83c0349b7d6f1
parent2089e6a689d99c9a33f1114a8fe066ee172bc826 (diff)
downloadmod_wsgi-c17aea2e76533cf0bfbad57c32741a26416dc187.tar.gz
Backport fix for excessive meory use when using read()/readline() with no
arguments. See issue #126.
-rw-r--r--README2
-rw-r--r--mod_wsgi.c16
2 files changed, 10 insertions, 8 deletions
diff --git a/README b/README
index d18e3f2..27a1aec 100644
--- a/README
+++ b/README
@@ -2,7 +2,7 @@
Welcome to MOD_WSGI
===================
-Copyright 2007 GRAHAM DUMPLETON
+Copyright 2007-2009 GRAHAM DUMPLETON
The mod_wsgi adapter is an Apache module that provides a WSGI compliant
interface for hosting Python based web applications within Apache. The
diff --git a/mod_wsgi.c b/mod_wsgi.c
index d0acdbb..fd1319e 100644
--- a/mod_wsgi.c
+++ b/mod_wsgi.c
@@ -1,7 +1,7 @@
/* vim: set sw=4 expandtab : */
/*
- * Copyright 2007-2008 GRAHAM DUMPLETON
+ * Copyright 2007-2009 GRAHAM DUMPLETON
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1684,14 +1684,16 @@ static PyObject *Input_read(InputObject *self, PyObject *args)
*/
while (!self->done) {
- /* Increase the size of the string by 25%. */
+ if (length == size) {
+ /* Increase the size of the string by 25%. */
- size = size + (size >> 2);
+ size = size + (size >> 2);
- if (_PyString_Resize(&result, size))
- return NULL;
+ if (_PyString_Resize(&result, size))
+ return NULL;
- buffer = PyString_AS_STRING((PyStringObject *)result);
+ buffer = PyString_AS_STRING((PyStringObject *)result);
+ }
/* Now make succesive attempt at reading data. */
@@ -1992,7 +1994,7 @@ static PyObject *Input_readline(InputObject *self, PyObject *args)
memcpy(self->buffer, p, self->size);
}
- if (buffer[length-1] != '\n') {
+ if (buffer[length-1] != '\n' && length == size) {
/* Increase size of string and keep going. */
size = size + (size >> 2);