Blame SOURCES/00186-memory-leak-marshalc.patch

ae2451
--- Python-2.7.5/Python/marshal.c	2013-05-12 05:32:53.000000000 +0200
ae2451
+++ /home/rkuska/hg/cpython/Python/marshal.c	2013-07-18 10:33:26.392486235 +0200
ae2451
@@ -88,7 +88,7 @@
ae2451
 }
ae2451
 
ae2451
 static void
ae2451
-w_string(char *s, Py_ssize_t n, WFILE *p)
ae2451
+w_string(const char *s, Py_ssize_t n, WFILE *p)
ae2451
 {
ae2451
     if (p->fp != NULL) {
ae2451
         fwrite(s, 1, n, p->fp);
ae2451
@@ -141,6 +141,13 @@
ae2451
 # define W_SIZE  w_long
ae2451
 #endif
ae2451
 
ae2451
+static void
ae2451
+w_pstring(const char *s, Py_ssize_t n, WFILE *p)
ae2451
+{
ae2451
+        W_SIZE(n, p);
ae2451
+        w_string(s, n, p);
ae2451
+}
ae2451
+
ae2451
 /* We assume that Python longs are stored internally in base some power of
ae2451
    2**15; for the sake of portability we'll always read and write them in base
ae2451
    exactly 2**15. */
ae2451
@@ -338,9 +345,7 @@
ae2451
         else {
ae2451
             w_byte(TYPE_STRING, p);
ae2451
         }
ae2451
-        n = PyString_GET_SIZE(v);
ae2451
-        W_SIZE(n, p);
ae2451
-        w_string(PyString_AS_STRING(v), n, p);
ae2451
+        w_pstring(PyBytes_AS_STRING(v), PyString_GET_SIZE(v), p);
ae2451
     }
ae2451
 #ifdef Py_USING_UNICODE
ae2451
     else if (PyUnicode_CheckExact(v)) {
ae2451
@@ -352,9 +357,7 @@
ae2451
             return;
ae2451
         }
ae2451
         w_byte(TYPE_UNICODE, p);
ae2451
-        n = PyString_GET_SIZE(utf8);
ae2451
-        W_SIZE(n, p);
ae2451
-        w_string(PyString_AS_STRING(utf8), n, p);
ae2451
+        w_pstring(PyString_AS_STRING(utf8), PyString_GET_SIZE(utf8), p);
ae2451
         Py_DECREF(utf8);
ae2451
     }
ae2451
 #endif
ae2451
@@ -441,8 +444,7 @@
ae2451
         PyBufferProcs *pb = v->ob_type->tp_as_buffer;
ae2451
         w_byte(TYPE_STRING, p);
ae2451
         n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s);
ae2451
-        W_SIZE(n, p);
ae2451
-        w_string(s, n, p);
ae2451
+        w_pstring(s, n, p);
ae2451
     }
ae2451
     else {
ae2451
         w_byte(TYPE_UNKNOWN, p);