shithub: pdffs

Download patch

ref: 1ba3f69232ba99ef7f31039b65f516eed2550f5d
parent: ff61dc11d08ab57aa1a4761a4ffbe46ec9d6fd6b
author: Noam Preil <[email protected]>
date: Thu Apr 7 10:43:08 EDT 2022

improve error handling

--- a/main.c
+++ b/main.c
@@ -111,15 +111,18 @@
 			v = nil;
 			break;
 		}else if(argv[i][0] == '!' && argv[i][1] == 0 && v->type == Odict && strcmp(dictget(v, "Type")->name, "Page") == 0){
-			dumppage(v, 0);
+			if(!dumppage(v, 0))
+				fprint(2, "page dump failed: %r\n");
 			nodump = 1;
 			break;
 		}else if(argv[i][0] == '"' && argv[i][1] == 0 && v->type == Odict && strcmp(dictget(v, "Type")->name, "Page") == 0){
-			dumppage(v, 1);
+			if(!dumppage(v, 1))
+				fprint(2, "page dump failed: %r\n");
 			nodump = 1;
 			break;
 		}else if(argv[i][0] == '"' && argv[i][1] == 0 && v->type == Odict && strcmp(dictget(v, "Type")->name, "Pages") == 0){
-			dumppages(v, 1);
+			if(!dumppages(v, 1))
+				fprint(2, "page dump failed: %r\n");
 			nodump = 1;
 			break;
 		}else if(argv[i][0] == '*' && argv[i][1] == 0 && v->type == Odict){
--- a/op.c
+++ b/op.c
@@ -1300,8 +1300,10 @@
 		if(s->buf.off == s->buf.sz)
 			break;
 		o = pdfobj(content->pdf, s);
-		if(o == nil)
+		if(o == nil){
+			werrstr("pagerendercontent: failed to parse op: %r");
 			return 0;
+		}
 		if(o->type == Oop){
 			op = opfind(o->str);
 			if(op == nil){