From 04bf36d1296a0fecac592a36acb0cfb1da6dce50 Mon Sep 17 00:00:00 2001 From: tanmayanand44 Date: Fri, 5 Jul 2019 19:16:43 +0530 Subject: [PATCH] Fixes crashing of imagetopdf when ppd is not provided --- filter/imagetopdf.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/filter/imagetopdf.c b/filter/imagetopdf.c index c4efc3e1f..606967b52 100644 --- a/filter/imagetopdf.c +++ b/filter/imagetopdf.c @@ -165,7 +165,7 @@ void emitJCLOptions(FILE *fp, int copies) datawritten = 1; } } - + snprintf(buf,sizeof(buf),"%d",copies); if (ppdFindOption(ppd,"Copies") != NULL) { ppdMarkOption(ppd,"Copies",buf); @@ -265,7 +265,7 @@ static void putcPdf(char c) static void outPdf(const char *str) { - unsigned long len = strlen(str); + unsigned long len = strlen(str); fputs(str,stdout); currentOffset += len; @@ -964,8 +964,8 @@ main(int argc, /* I - Number of command-line arguments */ int fidelity = 0; int document_large = 0; - if(ppd->custom_margins[0]||ppd->custom_margins[1]|| - ppd->custom_margins[2]||ppd->custom_margins[3]) // In case of custom margins + if(ppd && (ppd->custom_margins[0]||ppd->custom_margins[1]|| + ppd->custom_margins[2]||ppd->custom_margins[3])) // In case of custom margins margin_defined = 1; if(PageLength!=PageTop-PageBottom||PageWidth!=PageRight-PageLeft) margin_defined = 1; @@ -1104,7 +1104,7 @@ main(int argc, /* I - Number of command-line arguments */ if(temp1>w) temp1 = w; if(temp2>h) temp2 = h; if(temp3>h) temp3 = h; - if(temp4>w) temp4 = w; + if(temp4>w) temp4 = w; if(temp1*temp2jcl_ps by the value of this keyword, so that - ppdEmitJCL() actalually adds JCL based on the presence on + ppdEmitJCL() actalually adds JCL based on the presence on "*JCLToPDFInterpreter:". */ ppd_attr_t *attr; char buf[1024]; @@ -1599,12 +1599,12 @@ main(int argc, /* I - Number of command-line arguments */ snprintf(ppd->jcl_ps, size, "@PJL SET COPIES=%d\n%s", deviceCopies, attr->value); } - } + } else ppd->jcl_ps = strdup(attr->value); ppd_decode(ppd->jcl_ps); pdf_printer = 1; - } + } else { ppd->jcl_ps = NULL; -- 2.47.2