summaryrefslogtreecommitdiff
path: root/devices/gdevhl7x.c
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2019-11-11 20:14:36 -0800
committerRay Johnston <ray.johnston@artifex.com>2019-11-13 08:19:05 -0800
commitf63270230f329c6e89375af18d2bf2930421174a (patch)
tree97275cb35c3aa08663f0aff3c74fa2ae41c4a7f3 /devices/gdevhl7x.c
parent97277fcf0f70d482481ac329ce473e5687e7a935 (diff)
downloadghostpdl-f63270230f329c6e89375af18d2bf2930421174a.tar.gz
Fix devices that ignore return codes from gdev_prn get_bits & copy_scan_lines
Discovered these when working on bug 701845 'devicen' device. Checking uncovered a plethora of other places that used one of these functions assuming success. Also the gdev_prn_copy_scan_lines had places that assumed the return code was a valid line_count, so if negative, could memset many lines in front of an allocated buffer. The code in a few of these usages is strange, and we don't have a way to check them, so this may not match the original intent. Also, while perusing all of these files, check devices for alloc's that assume success and fix them (usually return gs_error_VMerror).
Diffstat (limited to 'devices/gdevhl7x.c')
-rw-r--r--devices/gdevhl7x.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/devices/gdevhl7x.c b/devices/gdevhl7x.c
index d2ed8f26e..1a3e59495 100644
--- a/devices/gdevhl7x.c
+++ b/devices/gdevhl7x.c
@@ -366,9 +366,11 @@ hl7x0_print_page(gx_device_printer *pdev, gp_file *printStream, int ptype,
storage + sizeOfBuffer, /* The line buffer is after the dump buffer */
&commandsBuffer,
&pageSummary);
+ if (result < 0)
+ goto xit;
dumpToPrinter(&commandsBuffer,printStream);
- } while (result == DumpContinue);
+ } while (result == DumpContinue); /* NB: at end of page, result will be DumpFinished == 0 */
/* end raster graphics and eject page */
initByteList(&formFeedCommand,
@@ -377,11 +379,12 @@ hl7x0_print_page(gx_device_printer *pdev, gp_file *printStream, int ptype,
sizeof(FormFeed)); /* First free byte */
dumpToPrinter(&formFeedCommand, printStream);
+xit:
/* free temporary storage */
freeSummary(pdev, &pageSummary);
gs_free(pdev->memory, (char *)storage, storage_size_words, 1, "hl7X0_print_page");
- return 0; /* If we reach this line, it means there was no error */
+ return result; /* If we reach this line, it means there was no error */
}
/*
@@ -463,6 +466,8 @@ static int dumpPage(gx_device_printer * pSource,
short lineNB;
short usefulLength;
short tmpLength;
+ int code = 0;
+
/* Initializations */
/* Make room for size of commands buffer */
pSaveCommandStart = currentPosition(pCommandList);
@@ -472,10 +477,12 @@ static int dumpPage(gx_device_printer * pSource,
for (lineNB = pSummary->nbLinesSent /*ERROR? + nbBlankLines */ ;
lineNB < pSummary->pageHeight ; lineNB ++ ) {
/* Fetch the line and put it into the buffer */
- gdev_prn_copy_scan_lines(pSource,
+ code = gdev_prn_copy_scan_lines(pSource,
lineNB,
pLineTmp,
pSummary->pageWidth);
+ if (code < 0)
+ return code;
usefulLength = stripTrailingBlanks(pLineTmp,pSummary->pageWidth);
if (usefulLength != 0) {