summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@jet.franken.de>2019-06-17 07:45:39 +0200
committerMarcus Meissner <marcus@jet.franken.de>2019-06-17 07:45:39 +0200
commit152345947f2f5415735131c018f2f4077ed8d944 (patch)
treee64216bbd3e5a5e9b074dfea183c71a5554bb8a4
parentd44b95ab149b85360c20787681a9b2baca68c877 (diff)
downloadlibgphoto2-152345947f2f5415735131c018f2f4077ed8d944.tar.gz
add some logging, avoid w and h < 2 to avoid division by 0 (AFL)
-rw-r--r--libgphoto2/bayer.c4
1 files changed, 4 insertions, 0 deletions
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 <gphoto2/gphoto2-port-log.h>
#include <gphoto2/gphoto2-result.h>
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: