summaryrefslogtreecommitdiff
path: root/util/cairo-script
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-08-14 11:33:27 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-08-14 12:37:57 +0100
commit9dc9f24884e1b580448f12ccd50909b6aee3cb53 (patch)
treee008b53d30e0498dd2214b2ef0c2c6642704cebb /util/cairo-script
parent23b1a82e88aab0413f832dbf445df5e302f1c30a (diff)
downloadcairo-9dc9f24884e1b580448f12ccd50909b6aee3cb53.tar.gz
script: leave the tail of the RGB24 data unmolested
We clear past the end of the row so that we don't trigger valgrind warning leaving harmless uninitialised bits inside the input image. However, for RGB24 the input rowlen is 3*width, whereas we write 4*width of data, so we need to take account of that and ensure we clear beyond the end of the written data, not the read data. Fixes reading of RGB24 input. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'util/cairo-script')
-rw-r--r--util/cairo-script/cairo-script-operators.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index 5904f5a16..9576f208a 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -2849,7 +2849,7 @@ _image_read_raw (csi_file_t *src,
{
cairo_surface_t *image;
uint8_t *bp, *data;
- int rem, len, ret, x, rowlen, stride;
+ int rem, len, ret, x, rowlen, instride, stride;
cairo_status_t status;
stride = cairo_format_stride_for_width (format, width);
@@ -2870,22 +2870,23 @@ _image_read_raw (csi_file_t *src,
switch (format) {
case CAIRO_FORMAT_A1:
- rowlen = (width+7)/8;
+ instride = rowlen = (width+7)/8;
break;
case CAIRO_FORMAT_A8:
- rowlen = width;
+ instride = rowlen = width;
break;
case CAIRO_FORMAT_RGB16_565:
- rowlen = 2 * width;
+ instride = rowlen = 2 * width;
break;
case CAIRO_FORMAT_RGB24:
rowlen = 3 * width;
+ instride = 4 *width;
break;
default:
case CAIRO_FORMAT_RGB30:
case CAIRO_FORMAT_INVALID:
case CAIRO_FORMAT_ARGB32:
- rowlen = 4 * width;
+ instride = rowlen = 4 * width;
break;
}
len = rowlen * height;
@@ -2951,7 +2952,7 @@ _image_read_raw (csi_file_t *src,
break;
}
- memset (row + rowlen, 0, stride - rowlen);
+ memset (row + instride, 0, stride - instride);
}
/* need to treat last row carefully */
@@ -3039,7 +3040,7 @@ _image_read_raw (csi_file_t *src,
/* stride == width */
break;
}
- memset (data + rowlen, 0, stride - rowlen);
+ memset (data + instride, 0, stride - instride);
} else {
#ifndef WORDS_BIGENDIAN
switch (format) {