forked from python-pillow/Pillow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
2,419 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from io import BytesIO | ||
|
||
import pytest | ||
|
||
from PIL import Image | ||
|
||
from .helper import is_win32, skip_unless_feature | ||
|
||
# Limits for testing the leak | ||
mem_limit = 1024 * 1048576 | ||
stack_size = 8 * 1048576 | ||
iterations = int((mem_limit / stack_size) * 2) | ||
test_file = "Tests/images/avif/hopper.avif" | ||
|
||
pytestmark = [ | ||
pytest.mark.skipif(is_win32(), reason="requires Unix or macOS"), | ||
skip_unless_feature("avif"), | ||
] | ||
|
||
|
||
def test_leak_load(): | ||
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit | ||
|
||
setrlimit(RLIMIT_STACK, (stack_size, stack_size)) | ||
setrlimit(RLIMIT_AS, (mem_limit, mem_limit)) | ||
for _ in range(iterations): | ||
with Image.open(test_file) as im: | ||
im.load() | ||
|
||
|
||
def test_leak_save(): | ||
from resource import RLIMIT_AS, RLIMIT_STACK, setrlimit | ||
|
||
setrlimit(RLIMIT_STACK, (stack_size, stack_size)) | ||
setrlimit(RLIMIT_AS, (mem_limit, mem_limit)) | ||
for _ in range(iterations): | ||
with Image.open(test_file) as im: | ||
im.load() | ||
test_output = BytesIO() | ||
im.save(test_output, "AVIF") | ||
test_output.seek(0) | ||
test_output.read() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.