Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8f505f2

Browse files
author
Steve Chaplin
committed
SC
svn path=/trunk/matplotlib/; revision=2987
1 parent 9cb48c1 commit 8f505f2

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

CHANGELOG

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
2007-01-15 src/_image.cpp combine buffer_argb32() and buffer_bgra32() into
1+
2007-01-16 src/_image.cpp: update to use Py_ssize_t (for 64-bit systems).
2+
Use return value of fread() to prevent warning messages - SC.
3+
4+
2007-01-15 src/_image.cpp: combine buffer_argb32() and buffer_bgra32() into
25
a new method color_conv(format) - SC
36

47
2007-01-14 backend_cairo.py: update draw_arc() so that

lib/matplotlib/backends/backend_gtkcairo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import cairo.gtk
88

99
from matplotlib.backends import backend_cairo
10-
from matplotlib.backends.backend_gtk import *
10+
from matplotlib.backends.backend_gtk import *
1111

1212
backend_version = 'PyGTK(%d.%d.%d) ' % gtk.pygtk_version + \
1313
'Pycairo(%s)' % backend_cairo.backend_version

src/_image.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,14 +232,16 @@ Image::color_conv(const Py::Tuple& args) {
232232
PyObject* py_buffer = PyBuffer_New(row_len * rowsOut);
233233
if (py_buffer ==NULL)
234234
throw Py::MemoryError("Image::color_conv could not allocate memory");
235-
unsigned char* buf;
236-
int buffer_len;
237-
int ret = PyObject_AsWriteBuffer(py_buffer, (void **)&buf, &buffer_len);
235+
236+
void* buf;
237+
Py_ssize_t buffer_len;
238+
int ret = PyObject_AsWriteBuffer(py_buffer, &buf, &buffer_len);
238239
if (ret !=0)
239240
throw Py::MemoryError("Image::color_conv could not allocate memory");
240241

241242
agg::rendering_buffer rtmp;
242-
rtmp.attach(buf, colsOut, rowsOut, row_len);
243+
rtmp.attach(reinterpret_cast<unsigned char*>(buf), colsOut, rowsOut,
244+
row_len);
243245

244246
switch (format) {
245247
case 0:
@@ -869,7 +871,8 @@ _image_module::readpng(const Py::Tuple& args) {
869871
if (!fp)
870872
throw Py::RuntimeError(Printf("_image_module::readpng could not open PNG file %s for reading", fname.c_str()).str());
871873

872-
fread(header, 1, 8, fp);
874+
if (fread(header, 1, 8, fp) != 8)
875+
throw Py::RuntimeError("_image_module::readpng: error reading PNG header");
873876
if (png_sig_cmp(header, 0, 8))
874877
throw Py::RuntimeError("_image_module::readpng: file not recognized as a PNG file");
875878

0 commit comments

Comments
 (0)