History

Avoid catastrophic failure when fz_count_pages returns negative value

malc committed 5 years ago

Commit 6d5dd2c1 parent e9073cc1 file · +6 −2Browse files

Unified · Split

link.c+6−2
@@ -338,6 +338,10 @@ static int openxref (char *filename, char *mimetype, char *password, · 337 unmodified lines
338338 fz_layout_document (state.ctx, state.doc, w, h, em);
339339 }
340340 state.pagecount = fz_count_pages (state.ctx, state.doc);
341+ if (state.pagecount < 0) {
342+ state.pagecount = 0;
343+ return 0;
344+ }
341345 return 1;
342346 }
343347
@@ -1351,8 +1355,8 @@ static void *mainloop (void UNUSED_ATTR *unused) · 1007 unmodified lines
13511355 }
13521356 fz_catch (state.ctx) {
13531357 utf8filename = mbtoutf8 (filename);
1354− printd ("emsg failed loading %s: %s",
1355− utf8filename, fz_caught_message (state.ctx));
1358+ printd ("emsg failed to load %s: %s", utf8filename,
1359+ fz_caught_message (state.ctx));
13561360 if (utf8filename != filename) {
13571361 free (utf8filename);
13581362 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t