Skip to content

Commit b300210

Browse files
committed
Fix Tk backend segfault.
svn path=/trunk/matplotlib/; revision=5140
1 parent 0e32eca commit b300210

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
2008-05-15 Fix Tk backend segfault on some machines - MGD
2+
13
2008-05-14 Don't use stat on Windows (fixes font embedding problem) - MGD
24

35
2008-05-09 Fix /singlequote (') in Postscript backend - MGD

src/_tkagg.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <Python.h>
1313
#include <stdlib.h>
14+
#include <sstream>
1415

1516
#include "agg_basics.h"
1617
#include "_backend_agg.h"
@@ -50,6 +51,7 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
5051
agg::int8u *destbuffer;
5152
double l,b,r,t;
5253
int destx, desty, destwidth, destheight, deststride;
54+
unsigned long tmp_ptr;
5355

5456
long mode;
5557
long nval;
@@ -71,7 +73,10 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
7173
return TCL_ERROR;
7274
}
7375
/* get array (or object that can be converted to array) pointer */
74-
aggo = (PyObject*)atol(argv[2]);
76+
std::stringstream agg_ptr_ss;
77+
agg_ptr_ss.str(argv[2]);
78+
agg_ptr_ss >> tmp_ptr;
79+
aggo = (PyObject*)tmp_ptr;
7580
RendererAgg *aggRenderer = (RendererAgg *)aggo;
7681
int srcheight = (int)aggRenderer->get_height();
7782

@@ -85,7 +90,10 @@ PyAggImagePhoto(ClientData clientdata, Tcl_Interp* interp,
8590
}
8691

8792
/* check for bbox/blitting */
88-
bboxo = (PyObject*)atol(argv[4]);
93+
std::stringstream bbox_ptr_ss;
94+
bbox_ptr_ss.str(argv[4]);
95+
bbox_ptr_ss >> tmp_ptr;
96+
bboxo = (PyObject*)tmp_ptr;
8997
if (py_convert_bbox(bboxo, l, b, r, t)) {
9098
has_bbox = true;
9199

0 commit comments

Comments
 (0)