Skip to content

Fix missing null dereference checks#9489

Open
wiredfool wants to merge 2 commits intopython-pillow:mainfrom
wiredfool:null_dereference
Open

Fix missing null dereference checks#9489
wiredfool wants to merge 2 commits intopython-pillow:mainfrom
wiredfool:null_dereference

Conversation

@wiredfool
Copy link
Member

@wiredfool wiredfool commented Mar 24, 2026

Changes proposed in this pull request:

  • _imaging.c:3767PyCapsule_SetContext(NULL) when PyCapsule_New fails
  • _webp.c:503 — NULL bytes to Py_BuildValue("Si") + Py_DECREF(NULL)
  • _avif.c:807 — NULL bytes to Py_BuildValue("SKKK") + Py_DECREF(NULL)
  • _avif.c:709 — Unchecked PyBytes_FromStringAndSize leaves active exception → SystemError
  • _imagingmorph.c:187,232 — NULL coordObj to PyList_Append (2 functions)
  • _imagingft.c:943PyCapsule_GetPointer(NULL) in font_render
  • _imaging.c:2471PyTuple_SET_ITEM on NULL tuple in _split

Thanks to @devdanzin for the report.


if (rgb.height > PY_SSIZE_T_MAX / rgb.rowBytes) {
PyErr_SetString(PyExc_MemoryError, "Integer overflow in pixel size");
// UNDONE avifRGBImageFreePixels(&rgb); ??
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to leave a GitHub comment explaining the uncertainty around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants