mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
Merge pull request #5909 from radarhere/transform
Fixed freeing pointer in ImageDraw.Outline.transform
This commit is contained in:
commit
7adab8f21f
|
@ -467,6 +467,23 @@ def test_shape2():
|
||||||
assert_image_equal_tofile(im, "Tests/images/imagedraw_shape2.png")
|
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):
|
def helper_pieslice(bbox, start, end):
|
||||||
# Arrange
|
# Arrange
|
||||||
im = Image.new("RGB", (W, H))
|
im = Image.new("RGB", (W, H))
|
||||||
|
|
|
@ -1854,14 +1854,8 @@ ImagingOutlineTransform(ImagingOutline outline, double a[6]) {
|
||||||
eIn = outline->edges;
|
eIn = outline->edges;
|
||||||
n = outline->count;
|
n = outline->count;
|
||||||
|
|
||||||
/* FIXME: ugly! */
|
|
||||||
outline->edges = NULL;
|
|
||||||
outline->count = outline->size = 0;
|
|
||||||
|
|
||||||
eOut = allocate(outline, n);
|
eOut = allocate(outline, n);
|
||||||
if (!eOut) {
|
if (!eOut) {
|
||||||
outline->edges = eIn;
|
|
||||||
outline->count = outline->size = n;
|
|
||||||
ImagingError_MemoryError();
|
ImagingError_MemoryError();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1897,7 +1891,11 @@ ImagingOutlineTransform(ImagingOutline outline, double a[6]) {
|
||||||
eOut++;
|
eOut++;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(eIn);
|
free(outline->edges);
|
||||||
|
|
||||||
|
/* FIXME: ugly! */
|
||||||
|
outline->edges = NULL;
|
||||||
|
outline->count = outline->size = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user