File: ttconv_leak_fix.patch

package info (click to toggle)
matplotlib 0.98.1-1%2Blenny4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 18,624 kB
  • ctags: 22,599
  • sloc: python: 76,915; cpp: 63,459; ansic: 5,353; makefile: 111; sh: 12
file content (85 lines) | stat: -rw-r--r-- 2,124 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Index: matplotlib-0.98.1/src/_ttconv.cpp
===================================================================
--- matplotlib-0.98.1.orig/src/_ttconv.cpp	2008-11-13 12:32:28.000000000 -0600
+++ matplotlib-0.98.1/src/_ttconv.cpp	2008-11-13 12:40:46.000000000 -0600
@@ -25,22 +25,23 @@
   }
 
   ~PythonFileWriter() {
-    if (_write_method)
-      Py_DECREF(_write_method);
+    Py_XDECREF(_write_method);
   }
 
   void set(PyObject* write_method) {
-    if (_write_method)
-      Py_DECREF(_write_method);
+    Py_XDECREF(_write_method);
     _write_method = write_method;
-    if (_write_method)
-      Py_INCREF(_write_method);
+    Py_XINCREF(_write_method);
   }
 
   virtual void write(const char* a) {
-    if (_write_method)
-      if (! PyObject_CallFunction(_write_method, (char *)"s", a))
-	throw PythonExceptionOccurred();
+    PyObject* result = NULL;
+    if (_write_method) {
+      result = PyObject_CallFunction(_write_method, (char *)"s", a);
+      if (! result)
+        throw PythonExceptionOccurred();
+      Py_DECREF(result);
+    }
   }
 };
 
@@ -54,6 +55,7 @@
   }
 
   file_writer->set(write_method);
+  Py_DECREF(write_method);
 
   return 1;
 }
@@ -68,11 +70,14 @@
   PyObject* item;
   while ( (item = PyIter_Next(iterator)) ) {
     long value = PyInt_AsLong(item);
+    Py_DECREF(item);
     if (value == -1 && PyErr_Occurred())
       return 0;
     result->push_back(value);
   }
 
+  Py_DECREF(iterator);
+
   return 1;
 }
 
@@ -130,9 +135,13 @@
 
   virtual void add_pair(const char* a, const char* b) {
     PyObject* value = PyString_FromString(b);
-    if (value)
-      if (PyDict_SetItemString(_dict, a, value))
+    if (value) {
+      if (PyDict_SetItemString(_dict, a, value)) {
+        Py_DECREF(value);
 	throw PythonExceptionOccurred();
+      }
+    }
+    Py_DECREF(value);
   }
 };
 
@@ -145,7 +154,7 @@
   static const char *kwlist[] = { "filename", "glyph_ids", NULL };
   if (! PyArg_ParseTupleAndKeywords
       (args, kwds,
-       "s|O&:convert_ttf_to_ps",
+       "s|O&:get_pdf_charprocs",
        (char **)kwlist,
        &filename,
        pyiterable_to_vector_int,