summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pdf/ghostpdf.c1
-rw-r--r--pdf/ghostpdf.h1
-rw-r--r--pdf/pdf_gstate.c20
3 files changed, 22 insertions, 0 deletions
diff --git a/pdf/ghostpdf.c b/pdf/ghostpdf.c
index bef6f7c33..e71d39649 100644
--- a/pdf/ghostpdf.c
+++ b/pdf/ghostpdf.c
@@ -378,6 +378,7 @@ const char *pdf_warning_strings[] = {
"failed to read a valid number, assuming 0",
"A DeviceN space used the /All ink name.",
"Couldn't retrieve MediaBox for page, using current media size",
+ "CA or ca value not in range 0.0 to 1.0, clamped to range.",
"" /* Last warning shuld not be used */
};
diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h
index 11aa6ab60..833ebaf5d 100644
--- a/pdf/ghostpdf.h
+++ b/pdf/ghostpdf.h
@@ -128,6 +128,7 @@ typedef enum pdf_warning_e {
W_PDF_INVALID_REAL,
W_PDF_DEVICEN_USES_ALL,
W_PDF_BAD_MEDIABOX,
+ W_PDF_CA_OUTOFRANGE,
W_PDF_MAX_WARNING /* Must be last entry, add new warnings immediately before this and update pdf_warning_strings in ghostpdf.c */
} pdf_warning;
diff --git a/pdf/pdf_gstate.c b/pdf/pdf_gstate.c
index 7544aa484..1ea6abc11 100644
--- a/pdf/pdf_gstate.c
+++ b/pdf/pdf_gstate.c
@@ -2199,6 +2199,16 @@ static int GS_CA(pdf_context *ctx, pdf_dict *GS, pdf_dict *stream_dict, pdf_dict
if (code < 0)
return code;
+ if (d1 > 1.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_CA", NULL);
+ d1 = 1.0;
+ }
+
+ if (d1 < 0.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_CA", NULL);
+ d1 = 0.0;
+ }
+
code = gs_setstrokeconstantalpha(ctx->pgs, d1);
return code;
}
@@ -2212,6 +2222,16 @@ static int GS_ca(pdf_context *ctx, pdf_dict *GS, pdf_dict *stream_dict, pdf_dict
if (code < 0)
return code;
+ if (d1 > 1.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_ca", NULL);
+ d1 = 1.0;
+ }
+
+ if (d1 < 0.0) {
+ pdfi_set_warning(ctx, 0, NULL, W_PDF_CA_OUTOFRANGE, "GS_ca", NULL);
+ d1 = 0.0;
+ }
+
code = gs_setfillconstantalpha(ctx->pgs, d1);
return code;
}