]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blame - python/patches/00186-memory-leak-marshalc.patch
python: Update to 2.7.5.
[people/ms/ipfire-3.x.git] / python / patches / 00186-memory-leak-marshalc.patch
CommitLineData
48d9a6a0
MT
1--- Python-2.7.5/Python/marshal.c 2013-05-12 05:32:53.000000000 +0200
2+++ /home/rkuska/hg/cpython/Python/marshal.c 2013-07-18 10:33:26.392486235 +0200
3@@ -88,7 +88,7 @@
4 }
5
6 static void
7-w_string(char *s, Py_ssize_t n, WFILE *p)
8+w_string(const char *s, Py_ssize_t n, WFILE *p)
9 {
10 if (p->fp != NULL) {
11 fwrite(s, 1, n, p->fp);
12@@ -141,6 +141,13 @@
13 # define W_SIZE w_long
14 #endif
15
16+static void
17+w_pstring(const char *s, Py_ssize_t n, WFILE *p)
18+{
19+ W_SIZE(n, p);
20+ w_string(s, n, p);
21+}
22+
23 /* We assume that Python longs are stored internally in base some power of
24 2**15; for the sake of portability we'll always read and write them in base
25 exactly 2**15. */
26@@ -338,9 +345,7 @@
27 else {
28 w_byte(TYPE_STRING, p);
29 }
30- n = PyString_GET_SIZE(v);
31- W_SIZE(n, p);
32- w_string(PyString_AS_STRING(v), n, p);
33+ w_pstring(PyBytes_AS_STRING(v), PyString_GET_SIZE(v), p);
34 }
35 #ifdef Py_USING_UNICODE
36 else if (PyUnicode_CheckExact(v)) {
37@@ -352,9 +357,7 @@
38 return;
39 }
40 w_byte(TYPE_UNICODE, p);
41- n = PyString_GET_SIZE(utf8);
42- W_SIZE(n, p);
43- w_string(PyString_AS_STRING(utf8), n, p);
44+ w_pstring(PyString_AS_STRING(utf8), PyString_GET_SIZE(utf8), p);
45 Py_DECREF(utf8);
46 }
47 #endif
48@@ -441,8 +444,7 @@
49 PyBufferProcs *pb = v->ob_type->tp_as_buffer;
50 w_byte(TYPE_STRING, p);
51 n = (*pb->bf_getreadbuffer)(v, 0, (void **)&s);
52- W_SIZE(n, p);
53- w_string(s, n, p);
54+ w_pstring(s, n, p);
55 }
56 else {
57 w_byte(TYPE_UNKNOWN, p);