FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

you can't call CGDataProviderCreateWithData on a stack pointer by lawrence-danna-apple · Pull Request #17263 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .m  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
24 changes: 12 additions & 12 deletions src/_macosx.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1585,24 +1585,25 @@ - (void)setCanvas: (PyObject*)newCanvas

static void _buffer_release(void* info, const void* data, size_t size) {
PyBuffer_Release((Py_buffer *)info);
free(info);
}

static int _copy_agg_buffer(CGContextRef cr, PyObject *renderer)
{
Py_buffer buffer;
Py_buffer *buffer = malloc(sizeof(Py_buffer));

if (PyObject_GetBuffer(renderer, &buffer, PyBUF_CONTIG_RO) == -1) {
if (PyObject_GetBuffer(renderer, buffer, PyBUF_CONTIG_RO) == -1) {
PyErr_Print();
return 1;
}

if (buffer.ndim != 3 || buffer.shape[2] != 4) {
PyBuffer_Release(&buffer);
if (buffer->ndim != 3 || buffer->shape[2] != 4) {
_buffer_release(buffer, NULL, 0);
return 1;
}

const Py_ssize_t nrows = buffer.shape[0];
const Py_ssize_t ncols = buffer.shape[1];
const Py_ssize_t nrows = buffer->shape[0];
const Py_ssize_t ncols = buffer->shape[1];
const size_t bytesPerComponent = 1;
const size_t bitsPerComponent = 8 * bytesPerComponent;
const size_t nComponents = 4; /* red, green, blue, alpha */
Expand All @@ -1611,16 +1612,16 @@ static int _copy_agg_buffer(CGContextRef cr, PyObject *renderer)

CGColorSpaceRef colorspace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
if (!colorspace) {
PyBuffer_Release(&buffer);
_buffer_release(buffer, NULL, 0);
return 1;
}

CGDataProviderRef provider = CGDataProviderCreateWithData(&buffer,
buffer.buf,
buffer.len,
CGDataProviderRef provider = CGDataProviderCreateWithData(buffer,
buffer->buf,
buffer->len,
_buffer_release);
if (!provider) {
PyBuffer_Release(&buffer);
_buffer_release(buffer, NULL, 0);
CGColorSpaceRelease(colorspace);
return 1;
}
Expand All @@ -1641,7 +1642,6 @@ static int _copy_agg_buffer(CGContextRef cr, PyObject *renderer)
CGDataProviderRelease(provider);

if (!bitmap) {
PyBuffer_Release(&buffer);
return 1;
}

Expand Down

Back | FazBrowse Home | New Git URL