From 9ce07167dc788175840236fca1711dc11ac69d15 Mon Sep 17 00:00:00 2001 From: David Hedberg Date: Tue, 9 Nov 2021 18:43:36 +1100 Subject: [PATCH] Fix an off-by-one error and a memory leak --- src/zbar_pipeline.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zbar_pipeline.c b/src/zbar_pipeline.c index 0fa5223..87f24ff 100644 --- a/src/zbar_pipeline.c +++ b/src/zbar_pipeline.c @@ -176,7 +176,7 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image) size_t i = 0; for (int y = 0; y < image->height; y += 2) { for (int x = 0; x < image->width; x += 2) { - data[++i] = image->data[x + image->width * y]; + data[i++] = image->data[x + image->width * y]; } } @@ -184,7 +184,7 @@ process_image(MPPipeline *pipeline, MPZBarImage **_image) zbar_image_t *zbar_image = zbar_image_create(); zbar_image_set_format(zbar_image, zbar_fourcc('Y', '8', '0', '0')); zbar_image_set_size(zbar_image, width, height); - zbar_image_set_data(zbar_image, data, width * height * sizeof(uint8_t), NULL); + zbar_image_set_data(zbar_image, data, width * height * sizeof(uint8_t), zbar_image_free_data); int res = zbar_scan_image(scanner, zbar_image); assert(res >= 0);