Skip to content

Commit

Permalink
Merge pull request #132 from tanmayanand44/master
Browse files Browse the repository at this point in the history
pdftoraster: Fix offset issues leading to segmentation faults in pdftoraster.
  • Loading branch information
tillkamppeter authored Jul 5, 2019
2 parents 9ee2c38 + a082eeb commit 2b8ea5f
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions filter/pdftoraster.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ static void writePageImage(cups_raster_t *raster, poppler::document *doc,
case CUPS_CSPACE_CMY:
case CUPS_CSPACE_RGBW:
default:
im = pr.render_page(current_page,header.HWResolution[0],header.HWResolution[1],0,0,header.cupsWidth,header.cupsHeight);
im = pr.render_page(current_page,header.HWResolution[0],header.HWResolution[1],bitmapoffset[0],bitmapoffset[1],header.cupsWidth,header.cupsHeight);
newdata = (unsigned char *)malloc(sizeof(char)*3*im.width()*im.height());
newdata = removeAlpha((unsigned char *)im.const_data(),newdata,im.width(),im.height());
pixel_count=im.width()*im.height();
Expand All @@ -1617,8 +1617,6 @@ static void writePageImage(cups_raster_t *raster, poppler::document *doc,
for (unsigned int plane = 0;plane < nplanes;plane++) {
unsigned char *bp = colordata;

bp += rowsize * (bitmapoffset[1] + header.cupsHeight - 1) +
popplerBitsPerPixel * bitmapoffset[0] / 8;
for (unsigned int h = header.cupsHeight;h > 0;h--) {
for (unsigned int band = 0;band < nbands;band++) {
dp = convertLine(bp,lineBuf,h,plane+band,header.cupsWidth,
Expand All @@ -1632,8 +1630,6 @@ static void writePageImage(cups_raster_t *raster, poppler::document *doc,
for (unsigned int plane = 0;plane < nplanes;plane++) {
unsigned char *bp = colordata;

bp += rowsize * bitmapoffset[1] +
popplerBitsPerPixel * bitmapoffset[0] / 8;
for (unsigned int h = 0;h < header.cupsHeight;h++) {
for (unsigned int band = 0;band < nbands;band++) {
dp = convertLine(bp,lineBuf,h,plane+band,header.cupsWidth,
Expand Down

0 comments on commit 2b8ea5f

Please sign in to comment.