Skip to content

Commit 20a9401

Browse files
committed
Check PyBytes_FromStringAndSize return value
1 parent 40400ed commit 20a9401

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

src/display.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,9 @@ PyImaging_GrabClipboardWin32(PyObject *self, PyObject *args) {
480480
GlobalUnlock(handle);
481481
CloseClipboard();
482482

483+
if (!result) {
484+
return NULL;
485+
}
483486
return Py_BuildValue("zN", format_names[format], result);
484487
}
485488

src/libImaging/codec_fd.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ _imaging_write_pyFd(PyObject *fd, char *src, Py_ssize_t bytes) {
4141
PyObject *byteObj;
4242

4343
byteObj = PyBytes_FromStringAndSize(src, bytes);
44+
if (!byteObj) {
45+
return -1;
46+
}
4447
result = PyObject_CallMethod(fd, "write", "O", byteObj);
4548

4649
Py_DECREF(byteObj);

0 commit comments

Comments
 (0)