#8 Skip PDF scan when content-size is 0

This commit is contained in:
simon 2019-11-21 16:04:29 -05:00
parent d089601dc5
commit 4ab2ba1a02

View File

@ -1,3 +1,4 @@
#include <src/ctx.h>
#include "pdf.h" #include "pdf.h"
#include "src/ctx.h" #include "src/ctx.h"
@ -185,6 +186,7 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
return; return;
} }
if (ScanCtx.content_size > 0) {
fz_stext_options opts = {0}; fz_stext_options opts = {0};
text_buffer_t text_buf = text_buffer_create(ScanCtx.content_size); text_buffer_t text_buf = text_buffer_create(ScanCtx.content_size);
@ -254,10 +256,11 @@ void parse_pdf(void *buf, size_t buf_len, document_t *doc) {
memcpy(meta_content->strval, text_buf.dyn_buffer.buf, text_buf.dyn_buffer.cur); memcpy(meta_content->strval, text_buf.dyn_buffer.buf, text_buf.dyn_buffer.cur);
APPEND_META(doc, meta_content) APPEND_META(doc, meta_content)
fz_drop_stream(ctx, stream);
fz_drop_document(ctx, fzdoc);
fz_drop_context(ctx);
text_buffer_destroy(&text_buf); text_buffer_destroy(&text_buf);
} }
fz_drop_stream(ctx, stream);
fz_drop_document(ctx, fzdoc);
fz_drop_context(ctx);
}