Skip to content

Commit 4994693

Browse files
author
greatriver
committed
Fix the crash bug
1 parent cc6db62 commit 4994693

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

source/hdtd/document.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ hd_open_document(hd_context *ctx, const char *filename)
6262
int i, score;
6363
int best_i, best_score;
6464
hd_document_handler_context *dc;
65-
hd_stream *file;
66-
hd_document *doc;
6765

6866
if (filename == NULL)
6967
hd_throw(ctx, HD_ERROR_GENERIC, "no document to open");

source/pdf/pdf-xref.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -932,10 +932,10 @@ pdf_load_object(hd_context *ctx, pdf_document *doc, int num)
932932
{
933933
pdf_xref_entry *entry = pdf_cache_object(ctx, doc, num);
934934
//assert(entry->obj != NULL);
935-
if (entry->obj != NULL)
936-
return pdf_keep_obj(ctx, entry->obj);
937-
else
938-
return NULL;
935+
if (entry->obj == NULL)
936+
hd_throw(ctx, HD_ERROR_GENERIC, "pdf_load_object is NULL");
937+
938+
return pdf_keep_obj(ctx, entry->obj);
939939
}
940940

941941
static void
@@ -1042,12 +1042,14 @@ pdf_init_document(hd_context *ctx, pdf_document *doc)
10421042
hd_try(ctx)
10431043
{
10441044
dict = pdf_load_object(ctx, doc, i);
1045-
if (dict == NULL)
1046-
hd_throw(ctx, HD_ERROR_GENERIC, "ignoring broken object (%d 0 R)", i);
1045+
/*if (dict == NULL)
1046+
hd_throw(ctx, HD_ERROR_GENERIC, "ignoring broken object (%d 0 R)", i);*/
10471047
}
10481048
hd_catch(ctx)
10491049
{
1050-
hd_rethrow(ctx);
1050+
hd_rethrow_if(ctx, HD_ERROR_TRYLATER);
1051+
hd_warn(ctx, "ignoring broken object (%d 0 R)", i);
1052+
continue;
10511053
}
10521054

10531055
if (!hasroot)
@@ -1078,7 +1080,8 @@ pdf_init_document(hd_context *ctx, pdf_document *doc)
10781080
}
10791081
hd_catch(ctx)
10801082
{
1081-
pdf_drop_obj(ctx, dict);
1083+
if (dict != NULL)
1084+
pdf_drop_obj(ctx, dict);
10821085
hd_rethrow(ctx);
10831086
}
10841087
}

0 commit comments

Comments
 (0)