~ubuntu-branches/ubuntu/wily/clamav/wily-proposed

« back to all changes in this revision

Viewing changes to .pc/0007-fix-ssize_t-size_t-off_t-printf-modifier.patch/libclamav/pdf.c

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-05-05 14:14:58 UTC
  • mfrom: (0.47.16)
  • Revision ID: package-import@ubuntu.com-20150505141458-mbkr5jjfu3j9gdvd
Tags: 0.98.7+dfsg-0ubuntu1
* Updated to 0.98.7 to fix multiple issues
  - CVE-2015-2170
  - CVE-2015-2221
  - CVE-2015-2222
  - CVE-2015-2305
  - CVE-2015-2668
* Refreshed patches for 0.98.7:
  - d/p/0005-libclamav-use-libmspack.patch
  - d/p/0007-fix-ssize_t-size_t-off_t-printf-modifier.patch
  - d/p/0008-hardcode-LLVM-linker-flag-because-llvm-config-return.patch
  - d/p/0015-llvm-don-t-use-system-libs.patch
* Removed upstreamed patches:
  - d/p/0012-remove-AC_CONFIG_SRCDIR-llvm-configure-from-libclama.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
#include "arc4.h"
60
60
#include "rijndael.h"
61
61
#include "textnorm.h"
 
62
#include "conv.h"
62
63
#include "json_api.h"
63
64
 
64
65
#ifdef  CL_DEBUG
746
747
}
747
748
 
748
749
 
749
 
static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, off_t *length, enum enc_method enc_method)
 
750
char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, off_t *length, enum enc_method enc_method)
750
751
{
751
752
    unsigned char *key, *q, result[16];
752
753
    unsigned n;
846
847
    return (char *)q;
847
848
}
848
849
 
849
 
static enum enc_method get_enc_method(struct pdf_struct *pdf, struct pdf_obj *obj)
 
850
enum enc_method get_enc_method(struct pdf_struct *pdf, struct pdf_obj *obj)
850
851
{
851
852
    if (obj->flags & (1 << OBJ_EMBEDDED_FILE))
852
853
        return pdf->enc_method_embeddedfile;
1240
1241
        }
1241
1242
    } while (0);
1242
1243
 
1243
 
    cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj to %s\n", sum, obj->id>>8, obj->id&0xff, fullname);
 
1244
    cli_dbgmsg("cli_pdf: extracted %ld bytes %u %u obj\n", sum, obj->id>>8, obj->id&0xff);
 
1245
    cli_dbgmsg("         ... to %s\n", fullname);
1244
1246
 
1245
1247
    if (flags & PDF_EXTRACT_OBJ_SCAN && sum) {
1246
1248
        int rc2;
2243
2245
    return ret;
2244
2246
}
2245
2247
 
2246
 
static void pdf_handle_enc(struct pdf_struct *pdf)
 
2248
void pdf_handle_enc(struct pdf_struct *pdf)
2247
2249
{
2248
2250
    struct pdf_obj *obj;
2249
2251
    uint32_t len, n, R, P, length, EM = 1, i, oulen;
3213
3215
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3214
3216
        return;
3215
3217
 
3216
 
    if (!(pdf->stats.author))
3217
 
        pdf->stats.author = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Author", NULL);
 
3218
    if (!(pdf->stats.author)) {
 
3219
        pdf->stats.author = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3220
        if (!(pdf->stats.author))
 
3221
            return;
 
3222
        pdf->stats.author->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Author", NULL, &(pdf->stats.author->meta));
 
3223
    }
3218
3224
}
3219
3225
#endif
3220
3226
 
3229
3235
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3230
3236
        return;
3231
3237
 
3232
 
    if (!(pdf->stats.creator))
3233
 
        pdf->stats.creator = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Creator", NULL);
 
3238
    if (!(pdf->stats.creator)) {
 
3239
        pdf->stats.creator = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3240
        if (!(pdf->stats.creator))
 
3241
            return;
 
3242
        pdf->stats.creator->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Creator", NULL, &(pdf->stats.creator->meta));
 
3243
    }
3234
3244
}
3235
3245
#endif
3236
3246
 
3245
3255
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3246
3256
        return;
3247
3257
 
3248
 
    if (!(pdf->stats.modificationdate))
3249
 
        pdf->stats.modificationdate = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/ModDate", NULL);
 
3258
    if (!(pdf->stats.modificationdate)) {
 
3259
        pdf->stats.modificationdate = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3260
        if (!(pdf->stats.modificationdate))
 
3261
            return;
 
3262
        pdf->stats.modificationdate->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/ModDate", NULL, &(pdf->stats.modificationdate->meta));
 
3263
    }
3250
3264
}
3251
3265
#endif
3252
3266
 
3261
3275
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3262
3276
        return;
3263
3277
 
3264
 
    if (!(pdf->stats.creationdate))
3265
 
        pdf->stats.creationdate = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/CreationDate", NULL);
 
3278
    if (!(pdf->stats.creationdate)) {
 
3279
        pdf->stats.creationdate = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3280
        if (!(pdf->stats.creationdate))
 
3281
            return;
 
3282
        pdf->stats.creationdate->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/CreationDate", NULL, &(pdf->stats.creationdate->meta));
 
3283
    }
3266
3284
}
3267
3285
#endif
3268
3286
 
3277
3295
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3278
3296
        return;
3279
3297
 
3280
 
    if (!(pdf->stats.producer))
3281
 
        pdf->stats.producer = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Producer", NULL);
 
3298
    if (!(pdf->stats.producer)) {
 
3299
        pdf->stats.producer = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3300
        if (!(pdf->stats.producer))
 
3301
            return;
 
3302
        pdf->stats.producer->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Producer", NULL, &(pdf->stats.producer->meta));
 
3303
    }
3282
3304
}
3283
3305
#endif
3284
3306
 
3293
3315
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3294
3316
        return;
3295
3317
 
3296
 
    if (!(pdf->stats.title))
3297
 
        pdf->stats.title = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Title", NULL);
 
3318
    if (!(pdf->stats.title)) {
 
3319
        pdf->stats.title = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3320
        if (!(pdf->stats.title))
 
3321
            return;
 
3322
        pdf->stats.title->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Title", NULL, &(pdf->stats.title->meta));
 
3323
    }
3298
3324
}
3299
3325
#endif
3300
3326
 
3309
3335
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3310
3336
        return;
3311
3337
 
3312
 
    if (!(pdf->stats.keywords))
3313
 
        pdf->stats.keywords = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Keywords", NULL);
 
3338
    if (!(pdf->stats.keywords)) {
 
3339
        pdf->stats.keywords = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3340
        if (!(pdf->stats.keywords))
 
3341
            return;
 
3342
        pdf->stats.keywords->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Keywords", NULL, &(pdf->stats.keywords->meta));
 
3343
    }
3314
3344
}
3315
3345
#endif
3316
3346
 
3325
3355
    if (!(pdf->ctx->options & CL_SCAN_FILE_PROPERTIES))
3326
3356
        return;
3327
3357
 
3328
 
    if (!(pdf->stats.subject))
3329
 
        pdf->stats.subject = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Subject", NULL);
 
3358
    if (!(pdf->stats.subject)) {
 
3359
        pdf->stats.subject = cli_calloc(1, sizeof(struct pdf_stats_entry));
 
3360
        if (!(pdf->stats.subject))
 
3361
            return;
 
3362
        pdf->stats.subject->data = pdf_parse_string(pdf, obj, obj->start + pdf->map, obj_size(pdf, obj, 1), "/Subject", NULL, &(pdf->stats.subject->meta));
 
3363
    }
3330
3364
}
3331
3365
#endif
3332
3366
 
3510
3544
        goto cleanup;
3511
3545
    }
3512
3546
 
3513
 
    if (pdf->stats.author)
3514
 
        cli_jsonstr(pdfobj, "Author", pdf->stats.author);
3515
 
    if (pdf->stats.creator)
3516
 
        cli_jsonstr(pdfobj, "Creator", pdf->stats.creator);
3517
 
    if (pdf->stats.producer)
3518
 
        cli_jsonstr(pdfobj, "Producer", pdf->stats.producer);
3519
 
    if (pdf->stats.modificationdate)
3520
 
        cli_jsonstr(pdfobj, "ModificationDate", pdf->stats.modificationdate);
3521
 
    if (pdf->stats.creationdate)
3522
 
        cli_jsonstr(pdfobj, "CreationDate", pdf->stats.creationdate);
3523
 
    if (pdf->stats.title)
3524
 
        cli_jsonstr(pdfobj, "Title", pdf->stats.title);
3525
 
    if (pdf->stats.subject)
3526
 
        cli_jsonstr(pdfobj, "Subject", pdf->stats.subject);
3527
 
    if (pdf->stats.keywords)
3528
 
        cli_jsonstr(pdfobj, "Keywords", pdf->stats.keywords);
 
3547
    if (pdf->stats.author) {
 
3548
        if (!pdf->stats.author->meta.success) {
 
3549
            char *out = pdf_finalize_string(pdf, pdf->stats.author->meta.obj, pdf->stats.author->data, pdf->stats.author->meta.length);
 
3550
            if (out) {
 
3551
                free(pdf->stats.author->data);
 
3552
                pdf->stats.author->data = out;
 
3553
                pdf->stats.author->meta.length = strlen(out);
 
3554
                pdf->stats.author->meta.success = 1;
 
3555
            }
 
3556
        }
 
3557
 
 
3558
        if (pdf->stats.author->meta.success && cli_isutf8(pdf->stats.author->data, pdf->stats.author->meta.length)) {
 
3559
            cli_jsonstr(pdfobj, "Author", pdf->stats.author->data);
 
3560
        } else if (pdf->stats.author->data && pdf->stats.author->meta.length) {
 
3561
            char *b64 = cl_base64_encode(pdf->stats.author->data, pdf->stats.author->meta.length);
 
3562
            cli_jsonstr(pdfobj, "Author", b64);
 
3563
            cli_jsonbool(pdfobj, "Author_base64", 1);
 
3564
            free(b64);
 
3565
        } else {
 
3566
            cli_jsonstr(pdfobj, "Author", "");
 
3567
        }
 
3568
    }
 
3569
    if (pdf->stats.creator) {
 
3570
        if (!pdf->stats.creator->meta.success) {
 
3571
            char *out = pdf_finalize_string(pdf, pdf->stats.creator->meta.obj, pdf->stats.creator->data, pdf->stats.creator->meta.length);
 
3572
            if (out) {
 
3573
                free(pdf->stats.creator->data);
 
3574
                pdf->stats.creator->data = out;
 
3575
                pdf->stats.creator->meta.length = strlen(out);
 
3576
                pdf->stats.creator->meta.success = 1;
 
3577
            }
 
3578
        }
 
3579
 
 
3580
        if (pdf->stats.creator->meta.success && cli_isutf8(pdf->stats.creator->data, pdf->stats.creator->meta.length)) {
 
3581
            cli_jsonstr(pdfobj, "Creator", pdf->stats.creator->data);
 
3582
        } else if (pdf->stats.creator->data && pdf->stats.creator->meta.length) {
 
3583
            char *b64 = cl_base64_encode(pdf->stats.creator->data, pdf->stats.creator->meta.length);
 
3584
            cli_jsonstr(pdfobj, "Creator", b64);
 
3585
            cli_jsonbool(pdfobj, "Creator_base64", 1);
 
3586
            free(b64);
 
3587
        } else {
 
3588
            cli_jsonstr(pdfobj, "Creator", "");
 
3589
        }
 
3590
    }
 
3591
    if (pdf->stats.producer) {
 
3592
        if (!pdf->stats.producer->meta.success) {
 
3593
            char *out = pdf_finalize_string(pdf, pdf->stats.producer->meta.obj, pdf->stats.producer->data, pdf->stats.producer->meta.length);
 
3594
            if (out) {
 
3595
                free(pdf->stats.producer->data);
 
3596
                pdf->stats.producer->data = out;
 
3597
                pdf->stats.producer->meta.length = strlen(out);
 
3598
                pdf->stats.producer->meta.success = 1;
 
3599
            }
 
3600
        }
 
3601
 
 
3602
        if (pdf->stats.producer->meta.success && cli_isutf8(pdf->stats.producer->data, pdf->stats.producer->meta.length)) {
 
3603
            cli_jsonstr(pdfobj, "Producer", pdf->stats.producer->data);
 
3604
        } else if (pdf->stats.producer->data && pdf->stats.producer->meta.length) {
 
3605
            char *b64 = cl_base64_encode(pdf->stats.producer->data, pdf->stats.producer->meta.length);
 
3606
            cli_jsonstr(pdfobj, "Producer", b64);
 
3607
            cli_jsonbool(pdfobj, "Producer_base64", 1);
 
3608
            free(b64);
 
3609
        } else {
 
3610
            cli_jsonstr(pdfobj, "Producer", "");
 
3611
        }
 
3612
    }
 
3613
    if (pdf->stats.modificationdate) {
 
3614
        if (!pdf->stats.modificationdate->meta.success) {
 
3615
            char *out = pdf_finalize_string(pdf, pdf->stats.modificationdate->meta.obj, pdf->stats.modificationdate->data, pdf->stats.modificationdate->meta.length);
 
3616
            if (out) {
 
3617
                free(pdf->stats.modificationdate->data);
 
3618
                pdf->stats.modificationdate->data = out;
 
3619
                pdf->stats.modificationdate->meta.length = strlen(out);
 
3620
                pdf->stats.modificationdate->meta.success = 1;
 
3621
            }
 
3622
        }
 
3623
 
 
3624
        if (pdf->stats.modificationdate->meta.success && cli_isutf8(pdf->stats.modificationdate->data, pdf->stats.modificationdate->meta.length)) {
 
3625
            cli_jsonstr(pdfobj, "ModificationDate", pdf->stats.modificationdate->data);
 
3626
        } else if (pdf->stats.modificationdate->data && pdf->stats.modificationdate->meta.length) {
 
3627
            char *b64 = cl_base64_encode(pdf->stats.modificationdate->data, pdf->stats.modificationdate->meta.length);
 
3628
            cli_jsonstr(pdfobj, "ModificationDate", b64);
 
3629
            cli_jsonbool(pdfobj, "ModificationDate_base64", 1);
 
3630
            free(b64);
 
3631
        } else {
 
3632
            cli_jsonstr(pdfobj, "ModificationDate", "");
 
3633
        }
 
3634
    }
 
3635
    if (pdf->stats.creationdate) {
 
3636
        if (!pdf->stats.creationdate->meta.success) {
 
3637
            char *out = pdf_finalize_string(pdf, pdf->stats.creationdate->meta.obj, pdf->stats.creationdate->data, pdf->stats.creationdate->meta.length);
 
3638
            if (out) {
 
3639
                free(pdf->stats.creationdate->data);
 
3640
                pdf->stats.creationdate->data = out;
 
3641
                pdf->stats.creationdate->meta.length = strlen(out);
 
3642
                pdf->stats.creationdate->meta.success = 1;
 
3643
            }
 
3644
        }
 
3645
 
 
3646
        if (pdf->stats.creationdate->meta.success && cli_isutf8(pdf->stats.creationdate->data, pdf->stats.creationdate->meta.length)) {
 
3647
            cli_jsonstr(pdfobj, "CreationDate", pdf->stats.creationdate->data);
 
3648
        } else if (pdf->stats.creationdate->data && pdf->stats.creationdate->meta.length) {
 
3649
            char *b64 = cl_base64_encode(pdf->stats.creationdate->data, pdf->stats.creationdate->meta.length);
 
3650
            cli_jsonstr(pdfobj, "CreationDate", b64);
 
3651
            cli_jsonbool(pdfobj, "CreationDate_base64", 1);
 
3652
            free(b64);
 
3653
        } else {
 
3654
            cli_jsonstr(pdfobj, "CreationDate", "");
 
3655
        }
 
3656
    }
 
3657
    if (pdf->stats.title) {
 
3658
        if (!pdf->stats.title->meta.success) {
 
3659
            char *out = pdf_finalize_string(pdf, pdf->stats.title->meta.obj, pdf->stats.title->data, pdf->stats.title->meta.length);
 
3660
            if (out) {
 
3661
                free(pdf->stats.title->data);
 
3662
                pdf->stats.title->data = out;
 
3663
                pdf->stats.title->meta.length = strlen(out);
 
3664
                pdf->stats.title->meta.success = 1;
 
3665
            }
 
3666
        }
 
3667
 
 
3668
        if (pdf->stats.title->meta.success && cli_isutf8(pdf->stats.title->data, pdf->stats.title->meta.length)) {
 
3669
            cli_jsonstr(pdfobj, "Title", pdf->stats.title->data);
 
3670
        } else if (pdf->stats.title->data && pdf->stats.title->meta.length) {
 
3671
            char *b64 = cl_base64_encode(pdf->stats.title->data, pdf->stats.title->meta.length);
 
3672
            cli_jsonstr(pdfobj, "Title", b64);
 
3673
            cli_jsonbool(pdfobj, "Title_base64", 1);
 
3674
            free(b64);
 
3675
        } else {
 
3676
            cli_jsonstr(pdfobj, "Title", "");
 
3677
        }
 
3678
    }
 
3679
    if (pdf->stats.subject) {
 
3680
        if (!pdf->stats.subject->meta.success) {
 
3681
            char *out = pdf_finalize_string(pdf, pdf->stats.subject->meta.obj, pdf->stats.subject->data, pdf->stats.subject->meta.length);
 
3682
            if (out) {
 
3683
                free(pdf->stats.subject->data);
 
3684
                pdf->stats.subject->data = out;
 
3685
                pdf->stats.subject->meta.length = strlen(out);
 
3686
                pdf->stats.subject->meta.success = 1;
 
3687
            }
 
3688
        }
 
3689
 
 
3690
        if (pdf->stats.subject->meta.success && cli_isutf8(pdf->stats.subject->data, pdf->stats.subject->meta.length)) {
 
3691
            cli_jsonstr(pdfobj, "Subject", pdf->stats.subject->data);
 
3692
        } else if (pdf->stats.subject->data && pdf->stats.subject->meta.length) {
 
3693
            char *b64 = cl_base64_encode(pdf->stats.subject->data, pdf->stats.subject->meta.length);
 
3694
            cli_jsonstr(pdfobj, "Subject", b64);
 
3695
            cli_jsonbool(pdfobj, "Subject_base64", 1);
 
3696
            free(b64);
 
3697
        } else {
 
3698
            cli_jsonstr(pdfobj, "Subject", "");
 
3699
        }
 
3700
    }
 
3701
    if (pdf->stats.keywords) {
 
3702
        if (!pdf->stats.keywords->meta.success) {
 
3703
            char *out = pdf_finalize_string(pdf, pdf->stats.keywords->meta.obj, pdf->stats.keywords->data, pdf->stats.keywords->meta.length);
 
3704
            if (out) {
 
3705
                free(pdf->stats.keywords->data);
 
3706
                pdf->stats.keywords->data = out;
 
3707
                pdf->stats.keywords->meta.length = strlen(out);
 
3708
                pdf->stats.keywords->meta.success = 1;
 
3709
            }
 
3710
        }
 
3711
 
 
3712
        if (pdf->stats.keywords->meta.success && cli_isutf8(pdf->stats.keywords->data, pdf->stats.keywords->meta.length)) {
 
3713
            cli_jsonstr(pdfobj, "Keywords", pdf->stats.keywords->data);
 
3714
        } else if (pdf->stats.keywords->data && pdf->stats.keywords->meta.length) {
 
3715
            char *b64 = cl_base64_encode(pdf->stats.keywords->data, pdf->stats.keywords->meta.length);
 
3716
            cli_jsonstr(pdfobj, "Keywords", b64);
 
3717
            cli_jsonbool(pdfobj, "Keywords_base64", 1);
 
3718
            free(b64);
 
3719
        } else {
 
3720
            cli_jsonstr(pdfobj, "Keywords", "");
 
3721
        }
 
3722
    }
3529
3723
    if (pdf->stats.ninvalidobjs)
3530
3724
        cli_jsonint(pdfobj, "InvalidObjectCount", pdf->stats.ninvalidobjs);
3531
3725
    if (pdf->stats.njs)
3588
3782
        cli_jsonbool(pdfobj, "Encrypted", 1);
3589
3783
        if (pdf->flags & (1 << DECRYPTABLE_PDF))
3590
3784
            cli_jsonbool(pdfobj, "Decryptable", 1);
 
3785
        else
 
3786
            cli_jsonbool(pdfobj, "Decryptable", 0);
3591
3787
    }
3592
3788
 
3593
3789
    for (i=0; i < pdf->nobjs; i++) {
3604
3800
 
3605
3801
cleanup:
3606
3802
    if ((pdf->stats.author)) {
 
3803
        if (pdf->stats.author->data)
 
3804
            free(pdf->stats.author->data);
3607
3805
        free(pdf->stats.author);
3608
3806
        pdf->stats.author = NULL;
3609
3807
    }
3610
3808
 
3611
3809
    if (pdf->stats.creator) {
 
3810
        if (pdf->stats.creator->data)
 
3811
            free(pdf->stats.creator->data);
3612
3812
        free(pdf->stats.creator);
3613
3813
        pdf->stats.creator = NULL;
3614
3814
    }
3615
3815
 
3616
3816
    if (pdf->stats.producer) {
 
3817
        if (pdf->stats.producer->data)
 
3818
            free(pdf->stats.producer->data);
3617
3819
        free(pdf->stats.producer);
3618
3820
        pdf->stats.producer = NULL;
3619
3821
    }
3620
3822
 
3621
3823
    if (pdf->stats.modificationdate) {
 
3824
        if (pdf->stats.modificationdate->data)
 
3825
            free(pdf->stats.modificationdate->data);
3622
3826
        free(pdf->stats.modificationdate);
3623
3827
        pdf->stats.modificationdate = NULL;
3624
3828
    }
3625
3829
 
3626
3830
    if (pdf->stats.creationdate) {
 
3831
        if (pdf->stats.creationdate->data)
 
3832
            free(pdf->stats.creationdate->data);
3627
3833
        free(pdf->stats.creationdate);
3628
3834
        pdf->stats.creationdate = NULL;
3629
3835
    }
3630
3836
 
3631
3837
    if (pdf->stats.title) {
 
3838
        if (pdf->stats.title->data)
 
3839
            free(pdf->stats.title->data);
3632
3840
        free(pdf->stats.title);
3633
3841
        pdf->stats.title = NULL;
3634
3842
    }
3635
3843
 
3636
3844
    if (pdf->stats.subject) {
 
3845
        if (pdf->stats.subject->data)
 
3846
            free(pdf->stats.subject->data);
3637
3847
        free(pdf->stats.subject);
3638
3848
        pdf->stats.subject = NULL;
3639
3849
    }
3640
3850
 
3641
3851
    if (pdf->stats.keywords) {
 
3852
        if (pdf->stats.keywords->data)
 
3853
            free(pdf->stats.keywords->data);
3642
3854
        free(pdf->stats.keywords);
3643
3855
        pdf->stats.keywords = NULL;
3644
3856
    }