summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-02-17 15:13:44 +0000
committerKen Sharp <ken.sharp@artifex.com>2022-02-17 15:41:03 +0000
commit011669503b626ea6a8a13851f652bdc0a64c4735 (patch)
tree6a6768f926eaa4bebf747936c9dd1014f57c2e44
parent1f2e9b2a9f54af7645bb2641ff7e716f93eb5d30 (diff)
downloadghostpdl-011669503b626ea6a8a13851f652bdc0a64c4735.tar.gz
Coverity ID 375528 - ensure we can't use negative array index
This looks like a potential real problem, if gx_path_optimise is set. I'm not sure this can ever happen, but it seems like the best thing to do is avoid the problem, we definitely don't want to index past the beginning of the segments array.
-rw-r--r--devices/vector/gdevpdfd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/devices/vector/gdevpdfd.c b/devices/vector/gdevpdfd.c
index c7cad3e56..ea40111be 100644
--- a/devices/vector/gdevpdfd.c
+++ b/devices/vector/gdevpdfd.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001-2021 Artifex Software, Inc.
+/* Copyright (C) 2001-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -499,7 +499,7 @@ static int pdf_write_path(gx_device_pdf * pdev, gs_path_enum *cenum, gdev_vector
buffering = 0;
seg_index = -1;
}
- if (type & gx_path_type_optimize) {
+ if (type & gx_path_type_optimize && seg_index > 0) {
if (segments[seg_index - 1].op == gs_pe_lineto) {
if (segments[seg_index].vs[0].x == segments[seg_index - 1].vs[0].x && segments[seg_index].vs[0].x == line_start.x) {
if (segments[seg_index - 1].vs[0].y > line_start.y && segments[seg_index].vs[0].y >= segments[seg_index - 1].vs[0].y) {