diff --git a/pdf.c b/pdf.c
index a193e66c4b8bb5b1665f3524ceeef5cba081f9f2..3b282184f21c92d3d3c6b73983f07c53cb54b3bf 100644
--- a/pdf.c
+++ b/pdf.c
@@ -4909,7 +4909,7 @@ parse_xrefs(struct Env *aux)
 	}
 	if (res == NULL) {
 		log_message(5, "VIOLATION[5]: startxref not found\n");
-		return;
+		goto end;
 	}
 	offset = H_INDEX_UINT(res->ast, 0);
 
@@ -4921,7 +4921,7 @@ parse_xrefs(struct Env *aux)
 	if ( (offset <=0) || (offset >= aux->sz) ) {
 		log_message(5, "VIOLATION[5]: Invalid xref table offset = %ld. Valid range <0, %ld>\n",
 				offset, aux->sz);
-		return;
+		goto end;
 	}
 
 	// XXX try formulating this loop as one parser using h_seek and h_bind
@@ -4976,6 +4976,7 @@ parse_xrefs(struct Env *aux)
 		offset = (size_t)tok->sint;
 	}
 
+end:
 	aux->xrefs = xrefs;
 	aux->nxrefs = n;
 }