commit b39508a7a5fde9f1b27a5ea1b05df1d2de685b54
parent fc2e9074d5f8c076c5f0d0725fee0689baad3be0
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 5 Sep 2006 23:07:07 +0000
fixing Mantis 1127 and 1130 (different PDF problems)
Diffstat:
3 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/plugins/pdf/PDFDoc.h b/src/plugins/pdf/PDFDoc.h
@@ -138,8 +138,8 @@ public:
GBool isLinearized();
// Return the document's Info dictionary (if any).
- Object *getDocInfo(Object *obj) { return xref->getDocInfo(obj); }
- Object *getDocInfoNF(Object *obj) { return xref->getDocInfoNF(obj); }
+ Object *getDocInfo(Object *obj) { return xref != NULL ? xref->getDocInfo(obj) : NULL; }
+ Object *getDocInfoNF(Object *obj) { return xref != NULL ? xref->getDocInfoNF(obj) : NULL; }
// Return the PDF version specified by the file.
double getPDFVersion() { return pdfVersion; }
diff --git a/src/plugins/pdf/pdfextractor.cc b/src/plugins/pdf/pdfextractor.cc
@@ -233,8 +233,8 @@ extern "C" {
result = addKeyword(EXTRACTOR_MIMETYPE,
strdup("application/pdf"),
prev);
- doc->getDocInfo(&info);
- if (info.isDict()) {
+ if ( (NULL != doc->getDocInfo(&info)) &&
+ (info.isDict()) ) {
result = printInfoString(info.getDict(),
"Title",
EXTRACTOR_TITLE,
diff --git a/src/plugins/pdfextractor.c b/src/plugins/pdfextractor.c
@@ -437,20 +437,25 @@ libextractor_pdf_extract(const char * filename,
pos - spos);
if (i == 0) {
dmeta = dateDecode(meta);
- mlen = strlen((const char*)dmeta);
+ if (dmeta != NULL)
+ mlen = strlen((const char*)dmeta);
+ else
+ mlen = 0;
} else {
dmeta = stringDecode(meta,
&mlen);
}
if (meta != NULL)
free(meta);
- meta = charsetDecode(dmeta, mlen);
- if (dmeta != NULL)
- free(dmeta);
- if (meta != NULL) {
- prev = addKeyword(tagmap[i].type,
- meta,
- prev);
+ if (dmeta != NULL) {
+ meta = charsetDecode(dmeta, mlen);
+ if (dmeta != NULL)
+ free(dmeta);
+ if (meta != NULL) {
+ prev = addKeyword(tagmap[i].type,
+ meta,
+ prev);
+ }
}
break;
}