Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for memory leaks in font handling #2634

Merged
merged 8 commits into from
Sep 4, 2017

Conversation

wiredfool
Copy link
Member

Fixes #2629 .

Changes proposed in this pull request:

  • Fix for memory leak in PILfont getsize
  • Fix for memory leak in truetype getsize

@wiredfool wiredfool added Bug Any unexpected behavior, until confirmed feature. Needs Tests labels Jul 18, 2017
_imaging.c Outdated
@@ -2196,6 +2215,7 @@ _font_getmask(ImagingFontObject* self, PyObject* args)
im = ImagingNew(self->bitmap->mode, textwidth(self, text), self->ysize);
if (!im) {
return NULL;
free(text);
Copy link
Member

Choose a reason for hiding this comment

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

After return

@wiredfool
Copy link
Member Author

wiredfool commented Aug 14, 2017

I'm not sure what's up with the Travis errors, as they're non-deterministic. This fails on debian-stretch in one commit or ubuntu-trusty-x86 in another, but the changes should not affect them.

======================================================================
FAIL: TestFontPcf.test_high_characters
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Pillow/Tests/test_font_pcf.py", line 59, in test_high_characters
    self._test_high_characters(message)
  File "/Pillow/Tests/test_font_pcf.py", line 55, in _test_high_characters
    self.assert_image_equal(image, compare)
  File "/Pillow/Tests/helper.py", line 85, in assert_image_equal
    msg or "got size %r, expected %r" % (a.size, b.size))
AssertionError: got size (770, 22), expected (765, 22)

(and when rerun, the ubuntu version passed, and the debian one still failed)

@wiredfool
Copy link
Member Author

This PR now has refactored out a PillowLeakTestCase into helper.py. It's got the current cross platform correct version of the get_mem_usage code from the png leak test case. We should convert the other memory checkers to this helper, so that they use the correct code.

@wiredfool wiredfool merged commit e71757a into python-pillow:master Sep 4, 2017
@wiredfool wiredfool deleted the issue_2629 branch October 2, 2017 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Any unexpected behavior, until confirmed feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants