Merge pull request #5909 from radarhere/transform

Fixed freeing pointer in ImageDraw.Outline.transform
This commit is contained in:
Andrew Murray 2021-12-27 16:25:24 +11:00 committed by GitHub
commit 7adab8f21f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 7 deletions

View File

@ -467,6 +467,23 @@ def test_shape2():
assert_image_equal_tofile(im, "Tests/images/imagedraw_shape2.png")
def test_transform():
# Arrange
im = Image.new("RGB", (100, 100), "white")
expected = im.copy()
draw = ImageDraw.Draw(im)
# Act
s = ImageDraw.Outline()
s.line(0, 0)
s.transform((0, 0, 0, 0, 0, 0))
draw.shape(s, fill=1)
# Assert
assert_image_equal(im, expected)
def helper_pieslice(bbox, start, end):
# Arrange
im = Image.new("RGB", (W, H))

View File

@ -1854,14 +1854,8 @@ ImagingOutlineTransform(ImagingOutline outline, double a[6]) {
eIn = outline->edges;
n = outline->count;
/* FIXME: ugly! */
outline->edges = NULL;
outline->count = outline->size = 0;
eOut = allocate(outline, n);
if (!eOut) {
outline->edges = eIn;
outline->count = outline->size = n;
ImagingError_MemoryError();
return -1;
}
@ -1897,7 +1891,11 @@ ImagingOutlineTransform(ImagingOutline outline, double a[6]) {
eOut++;
}
free(eIn);
free(outline->edges);
/* FIXME: ugly! */
outline->edges = NULL;
outline->count = outline->size = 0;
return 0;
}