diff --git a/src/_backend_agg.cpp b/src/_backend_agg.cpp index 416a3991f4ad..a392ce5c9f5e 100644 --- a/src/_backend_agg.cpp +++ b/src/_backend_agg.cpp @@ -2420,6 +2420,12 @@ RendererAgg::tostring_rgba_minimized(const Py::Tuple& args) *dst = src[y * width + x]; } } + } else { + data = PyBytes_FromStringAndSize(NULL, 0); + if (data == NULL) + { + throw Py::MemoryError("RendererAgg::tostring_minimized could not allocate memory"); + } } Py::Tuple bounds(4);