Skip to content

Commit dfaa15a

Browse files
tests/: added test_4712() and test_4712m().
Crash with "corrupted double-linked list". Both tests are disabled for now because they segv.
1 parent d487e15 commit dfaa15a

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

tests/resources/test_4712_a.pdf

2.85 KB
Binary file not shown.

tests/resources/test_4712_b.pdf

3.25 KB
Binary file not shown.

tests/test_general.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,3 +2117,66 @@ def test_4702():
21172117
_ = document.xref_object(xref)
21182118
wt = pymupdf.TOOLS.mupdf_warnings()
21192119
assert wt == 'repairing PDF document'
2120+
2121+
2122+
def test_4712():
2123+
'''
2124+
Crash with "corrupted double-linked list
2125+
'''
2126+
if 1:
2127+
print(f'test_4712(): Not running because known to fail.')
2128+
return
2129+
path_a = os.path.normpath(f'{__file__}/../../tests/resources/test_4712_a.pdf')
2130+
path_b = os.path.normpath(f'{__file__}/../../tests/resources/test_4712_b.pdf')
2131+
doc1 = pymupdf.open(path_a)
2132+
for i in range(6):
2133+
doc1.load_page(i).get_pixmap()
2134+
doc2 = pymupdf.open(path_b)
2135+
for i in range(6):
2136+
doc2.load_page(i).get_pixmap()
2137+
2138+
2139+
def test_4712m():
2140+
if 1:
2141+
print(f'test_4712b(): Not running because known to fail.')
2142+
return
2143+
2144+
path_a = os.path.normpath(f'{__file__}/../../tests/resources/test_4712_a.pdf')
2145+
path_b = os.path.normpath(f'{__file__}/../../tests/resources/test_4712_b.pdf')
2146+
2147+
mupdf = pymupdf.mupdf
2148+
def get_pixmap(page):
2149+
displaylist = mupdf.fz_new_display_list_from_page(page)
2150+
rect = mupdf.fz_bound_display_list(displaylist)
2151+
irect = mupdf.fz_round_rect(rect)
2152+
pixmap = mupdf.fz_new_pixmap_with_bbox(
2153+
mupdf.FzColorspace(mupdf.FzColorspace.Fixed_RGB),
2154+
irect,
2155+
mupdf.FzSeparations(),
2156+
0, # alpha
2157+
)
2158+
mupdf.fz_clear_pixmap_with_value(pixmap, 0xFF)
2159+
matrix = mupdf.FzMatrix()
2160+
device = mupdf.fz_new_draw_device(matrix, pixmap)
2161+
mupdf.fz_run_display_list(
2162+
displaylist,
2163+
device,
2164+
mupdf.FzMatrix(),
2165+
mupdf.FzRect(mupdf.FzRect.Fixed_INFINITE),
2166+
mupdf.FzCookie(),
2167+
)
2168+
mupdf.fz_close_device(device)
2169+
2170+
def process_document(document):
2171+
for i in range(6):
2172+
print(f' {i=}', flush=1)
2173+
page = mupdf.fz_load_page(document, i)
2174+
get_pixmap(page)
2175+
2176+
print(f'Processing {path_a=}', flush=1)
2177+
document_a = mupdf.fz_open_document(path_a)
2178+
process_document(document_a)
2179+
2180+
print(f'Processing {path_b=}', flush=1)
2181+
document_b = mupdf.fz_open_document(path_b)
2182+
process_document(document_b)

0 commit comments

Comments
 (0)