From 152345947f2f5415735131c018f2f4077ed8d944 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Mon, 17 Jun 2019 07:45:39 +0200 Subject: add some logging, avoid w and h < 2 to avoid division by 0 (AFL) --- libgphoto2/bayer.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libgphoto2/bayer.c b/libgphoto2/bayer.c index 3ba72ba6c..36414017e 100644 --- a/libgphoto2/bayer.c +++ b/libgphoto2/bayer.c @@ -31,6 +31,7 @@ #include "config.h" #include "bayer.h" +#include #include static const int tile_colours[8][4] = { @@ -78,6 +79,7 @@ gp_bayer_expand (unsigned char *input, int w, int h, unsigned char *output, int colour, bayer; unsigned char *ptr = input; + gp_log (GP_LOG_DEBUG, "bayer", "w=%d, h=%d\n", w, h); switch (tile) { case BAYER_TILE_RGGB: @@ -148,6 +150,8 @@ gp_bayer_interpolate (unsigned char *image, int w, int h, BayerTile tile) int p0, p1, p2; int value, div ; + if (w < 2 || h < 2) return GP_ERROR; + switch (tile) { default: case BAYER_TILE_RGGB: -- cgit v1.2.1