diff options
Diffstat (limited to 'devices/gdevescp.c')
-rw-r--r-- | devices/gdevescp.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/devices/gdevescp.c b/devices/gdevescp.c index 00043192..005fa58a 100644 --- a/devices/gdevescp.c +++ b/devices/gdevescp.c @@ -119,7 +119,7 @@ escp2_print_page(gx_device_printer *pdev, gp_file *prn_stream) byte *out = buf2; int skip, lnum, top, bottom, left, width; - int count, i; + int code = 0, count, i; /* ** Check for valid resolution: @@ -141,12 +141,9 @@ escp2_print_page(gx_device_printer *pdev, gp_file *prn_stream) ** Check buffer allocations: */ - if ( buf1 == 0 || buf2 == 0 ) - { if ( buf1 ) - gs_free(pdev->memory, (char *)buf1, in_size, 1, "escp2_print_page(buf1)"); - if ( buf2 ) - gs_free(pdev->memory, (char *)buf2, in_size, 1, "escp2_print_page(buf2)"); - return_error(gs_error_VMerror); + if ( buf1 == 0 || buf2 == 0 ) { + code = gs_error_VMerror; + goto xit; } /* @@ -218,14 +215,18 @@ escp2_print_page(gx_device_printer *pdev, gp_file *prn_stream) ** Check buffer for 0 data. We can't do this mid-band */ - gdev_prn_get_bits(pdev, lnum, in, &in_data); + code = gdev_prn_get_bits(pdev, lnum, in, &in_data); + if (code < 0) + goto xit; while ( in_data[0] == 0 && !memcmp((char *)in_data, (char *)in_data + 1, line_size - 1) && lnum < bottom ) { lnum++; skip++; - gdev_prn_get_bits(pdev, lnum, in, &in_data); + code = gdev_prn_get_bits(pdev, lnum, in, &in_data); + if (code < 0) + goto xit; } if(lnum == bottom ) break; /* finished with this page */ @@ -241,7 +242,9 @@ escp2_print_page(gx_device_printer *pdev, gp_file *prn_stream) skip = 0; } - lcnt = gdev_prn_copy_scan_lines(pdev, lnum, in, in_size); + code = lcnt = gdev_prn_copy_scan_lines(pdev, lnum, in, in_size); + if (lcnt < 0) + goto xit; /* ** Check to see if we don't have enough data to fill an entire @@ -403,7 +406,13 @@ escp2_print_page(gx_device_printer *pdev, gp_file *prn_stream) gp_fputs("\f\033@", prn_stream); gp_fflush(prn_stream); - gs_free(pdev->memory, (char *)buf2, in_size, 1, "escp2_print_page(buf2)"); - gs_free(pdev->memory, (char *)buf1, in_size, 1, "escp2_print_page(buf1)"); - return 0; +xit: + if ( buf1 ) + gs_free(pdev->memory, (char *)buf1, in_size, 1, "escp2_print_page(buf1)"); + if ( buf2 ) + gs_free(pdev->memory, (char *)buf2, in_size, 1, "escp2_print_page(buf2)"); + if (code < 0) + return_error(code); + + return code; } |