Browse code

bb11296 - fix segfault in pdf file properties.

Steven Morgan authored on 2015/04/09 00:09:52
Showing 1 changed files
... ...
@@ -3556,7 +3556,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3556 3556
 
3557 3557
         if (pdf->stats.author->meta.success && cli_isutf8(pdf->stats.author->data, pdf->stats.author->meta.length)) {
3558 3558
             cli_jsonstr(pdfobj, "Author", pdf->stats.author->data);
3559
-        } else {
3559
+        } else if (pdf->stats.author->data && pdf->stats.author->meta.length) {
3560 3560
             char *b64 = (char *)cl_base64_encode(pdf->stats.author->data, pdf->stats.author->meta.length);
3561 3561
             cli_jsonstr(pdfobj, "Author", b64);
3562 3562
             cli_jsonbool(pdfobj, "Author_base64", 1);
... ...
@@ -3576,7 +3576,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3576 3576
 
3577 3577
         if (pdf->stats.creator->meta.success && cli_isutf8(pdf->stats.creator->data, pdf->stats.creator->meta.length)) {
3578 3578
             cli_jsonstr(pdfobj, "Creator", pdf->stats.creator->data);
3579
-        } else {
3579
+        } else if (pdf->stats.creator->data && pdf->stats.creator->meta.length) {
3580 3580
             char *b64 = (char *)cl_base64_encode(pdf->stats.creator->data, pdf->stats.creator->meta.length);
3581 3581
             cli_jsonstr(pdfobj, "Creator", b64);
3582 3582
             cli_jsonbool(pdfobj, "Creator_base64", 1);
... ...
@@ -3596,7 +3596,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3596 3596
 
3597 3597
         if (pdf->stats.producer->meta.success && cli_isutf8(pdf->stats.producer->data, pdf->stats.producer->meta.length)) {
3598 3598
             cli_jsonstr(pdfobj, "Producer", pdf->stats.producer->data);
3599
-        } else {
3599
+        } else if (pdf->stats.producer->data && pdf->stats.producer->meta.length) {
3600 3600
             char *b64 = (char *)cl_base64_encode(pdf->stats.producer->data, pdf->stats.producer->meta.length);
3601 3601
             cli_jsonstr(pdfobj, "Producer", b64);
3602 3602
             cli_jsonbool(pdfobj, "Producer_base64", 1);
... ...
@@ -3616,7 +3616,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3616 3616
 
3617 3617
         if (pdf->stats.modificationdate->meta.success && cli_isutf8(pdf->stats.modificationdate->data, pdf->stats.modificationdate->meta.length)) {
3618 3618
             cli_jsonstr(pdfobj, "ModificationDate", pdf->stats.modificationdate->data);
3619
-        } else {
3619
+        } else if (pdf->stats.modificationdate->data && pdf->stats.modificationdate->meta.length) {
3620 3620
             char *b64 = (char *)cl_base64_encode(pdf->stats.modificationdate->data, pdf->stats.modificationdate->meta.length);
3621 3621
             cli_jsonstr(pdfobj, "ModificationDate", b64);
3622 3622
             cli_jsonbool(pdfobj, "ModificationDate_base64", 1);
... ...
@@ -3636,7 +3636,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3636 3636
 
3637 3637
         if (pdf->stats.creationdate->meta.success && cli_isutf8(pdf->stats.creationdate->data, pdf->stats.creationdate->meta.length)) {
3638 3638
             cli_jsonstr(pdfobj, "CreationDate", pdf->stats.creationdate->data);
3639
-        } else {
3639
+        } else if (pdf->stats.creationdate->data && pdf->stats.creationdate->meta.length) {
3640 3640
             char *b64 = (char *)cl_base64_encode(pdf->stats.creationdate->data, pdf->stats.creationdate->meta.length);
3641 3641
             cli_jsonstr(pdfobj, "CreationDate", b64);
3642 3642
             cli_jsonbool(pdfobj, "CreationDate_base64", 1);
... ...
@@ -3656,7 +3656,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3656 3656
 
3657 3657
         if (pdf->stats.title->meta.success && cli_isutf8(pdf->stats.title->data, pdf->stats.title->meta.length)) {
3658 3658
             cli_jsonstr(pdfobj, "Title", pdf->stats.title->data);
3659
-        } else {
3659
+        } else if (pdf->stats.title->data && pdf->stats.title->meta.length) {
3660 3660
             char *b64 = (char *)cl_base64_encode(pdf->stats.title->data, pdf->stats.title->meta.length);
3661 3661
             cli_jsonstr(pdfobj, "Title", b64);
3662 3662
             cli_jsonbool(pdfobj, "Title_base64", 1);
... ...
@@ -3676,7 +3676,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3676 3676
 
3677 3677
         if (pdf->stats.subject->meta.success && cli_isutf8(pdf->stats.subject->data, pdf->stats.subject->meta.length)) {
3678 3678
             cli_jsonstr(pdfobj, "Subject", pdf->stats.subject->data);
3679
-        } else {
3679
+        } else if (pdf->stats.subject->data && pdf->stats.subject->meta.length) {
3680 3680
             char *b64 = (char *)cl_base64_encode(pdf->stats.subject->data, pdf->stats.subject->meta.length);
3681 3681
             cli_jsonstr(pdfobj, "Subject", b64);
3682 3682
             cli_jsonbool(pdfobj, "Subject_base64", 1);
... ...
@@ -3696,7 +3696,7 @@ static void pdf_export_json(struct pdf_struct *pdf)
3696 3696
 
3697 3697
         if (pdf->stats.keywords->meta.success && cli_isutf8(pdf->stats.keywords->data, pdf->stats.keywords->meta.length)) {
3698 3698
             cli_jsonstr(pdfobj, "Keywords", pdf->stats.keywords->data);
3699
-        } else {
3699
+        } else if (pdf->stats.keywords->data && pdf->stats.keywords->meta.length) {
3700 3700
             char *b64 = (char *)cl_base64_encode(pdf->stats.keywords->data, pdf->stats.keywords->meta.length);
3701 3701
             cli_jsonstr(pdfobj, "Keywords", b64);
3702 3702
             cli_jsonbool(pdfobj, "Keywords_base64", 1);