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
338 fz_layout_document (state.ctx, state.doc, w, h, em);338 fz_layout_document (state.ctx, state.doc, w, h, em);
339 }339 }
340 state.pagecount = fz_count_pages (state.ctx, state.doc);340 state.pagecount = fz_count_pages (state.ctx, state.doc);
341 if (state.pagecount < 0) {
342 state.pagecount = 0;
343 return 0;
344 }
341 return 1;345 return 1;
342}346}
343 347
@@ -1351,8 +1355,8 @@ static void *mainloop (void UNUSED_ATTR *unused) · 1007 unmodified lines
1351 }1355 }
1352 fz_catch (state.ctx) {1356 fz_catch (state.ctx) {
1353 utf8filename = mbtoutf8 (filename);1357 utf8filename = mbtoutf8 (filename);
1354 printd ("emsg failed loading %s: %s",1358 printd ("emsg failed to load %s: %s", utf8filename,
1355 utf8filename, fz_caught_message (state.ctx));1359 fz_caught_message (state.ctx));
1356 if (utf8filename != filename) {1360 if (utf8filename != filename) {
1357 free (utf8filename);1361 free (utf8filename);
1358 }1362 }

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