8000 Correctly handle invalid PNG metadata. · timhoffm/matplotlib@511df0f · GitHub
[go: up one dir, main page]

Skip to content

Commit 511df0f

Browse files
committed
Correctly handle invalid PNG metadata.
1 parent a7a3f2a commit 511df0f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/_png.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ static PyObject *Py_write_png(PyObject *self, PyObject *args, PyObject *kwds)
300300

301301
#ifdef PNG_TEXT_SUPPORTED
302302
// Save the metadata
303-
if (metadata != NULL) {
303+
if (metadata != NULL && metadata != Py_None) {
304+
if (!PyDict_Check(metadata)) {
305+
PyErr_SetString(PyExc_TypeError, "metadata must be a dict or None");
306+
goto exit;
307+
}
304308
meta_size = PyDict_Size(metadata);
305309
text = new png_text[meta_size];
306310

0 commit comments

Comments
 (0)
0