matplotlib / matplotlib/fcpy

Potential Memory Leak

Open
#6 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
2
PR merge metrics
No merged PRs in 30d

Description

In `src/constants.c`, if the `PyNumber_And` call fails, the routine returns without disposing of allocated objects.

[Enclosed](https://github.com/matplotlib/fcpy/files/1291248/ldo-memleak-patch-20170911.txt) is a patch that fixes this, while regularizing the handling of cleanup on errors in an easier-to-understand, more structured fashion, avoiding `goto`s. Even with explicitly spelling out `PyErr_Occurred()` calls everywhere, the code is still slightly shorter.

But I think a C extension library requires too much work for this kind of thing. A more complete binding for Fontconfig can be done in pure Python with [much less code](https://github.com/ldo/python_fontconfig).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading src/constants.c and comparing its PyNumber_And failure path with the attached patch. Confirm that allocated objects are disposed of on that failure and that the error cleanup paths are handled consistently; completion is a leak-free routine on those error paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, python
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.