From 9fda48ab304a920629d1337d6004ae31972c7307 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 14 Oct 2020 10:32:29 +0200 Subject: [PATCH] adding mollyguard --- funcs/classif.c | 12 +++++++++++- funcs/contour2x2.c | 10 ++++++++++ funcs/qsortrgb.c | 20 +++++++++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/funcs/classif.c b/funcs/classif.c index eb6dc373..9e4fd60b 100644 --- a/funcs/classif.c +++ b/funcs/classif.c @@ -21,9 +21,19 @@ float range, dist, rgb[3], dr, dg, db; int x, y, on, off; #if DEBUG_LEVEL -fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__, psrc, pdst, fval, notused); +fprintf(stderr, ">>> %s ( %p %p %f %d )\n", __func__, + psrc, pdst, fval, notused); #endif +if (FIMG_TYPE_RGB != psrc->type) { + fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); + return -7; + } +if (fimg_images_not_compatible(psrc, pdst)) { + fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type); + return -8; + } + /* calculer les amplitudes RGB de l'image source */ fimg_get_minmax_rgb(psrc, minmax); delta[0] = minmax[1] - minmax[0]; diff --git a/funcs/contour2x2.c b/funcs/contour2x2.c index 804a95c0..0c3add96 100644 --- a/funcs/contour2x2.c +++ b/funcs/contour2x2.c @@ -32,6 +32,16 @@ int tbl[] = /* deep magic inside */ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, reverse); #endif +if (FIMG_TYPE_RGB != psrc->type) { + fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); + return -7; + } +if (fimg_images_not_compatible(psrc, pdst)) { + fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type); + return -8; + } + + if (reverse) { v1 = 0.0; v2 = 1.0; } diff --git a/funcs/qsortrgb.c b/funcs/qsortrgb.c index 6a1a96a9..dd801f86 100644 --- a/funcs/qsortrgb.c +++ b/funcs/qsortrgb.c @@ -27,6 +27,15 @@ int foo, szimg; fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); #endif +if (FIMG_TYPE_RGB != psrc->type) { + fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); + return -7; + } +if (fimg_images_not_compatible(psrc, pdst)) { + fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type); + return -8; + } + foo = fimg_copy_data(psrc, pdst); szimg = pdst->width * pdst->height; @@ -44,7 +53,7 @@ typedef struct { float r, g, b; } pix; -static compare_b(const void *p1, const void *p2) +static int compare_b(const void *p1, const void *p2) { pix *s1, *s2; s1 = (pix *)p1; @@ -62,6 +71,15 @@ float rgb[3]; fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, psrc, pdst, notused); #endif +if (FIMG_TYPE_RGB != psrc->type) { + fprintf(stderr, "%s: bad src type %d\n", __func__, psrc->type); + return -7; + } +if (fimg_images_not_compatible(psrc, pdst)) { + fprintf(stderr, "%s: bad dst type %d\n", __func__, pdst->type); + return -8; + } + szimg = pdst->width * pdst->height; fprintf(stderr, "%s : %d pixels\n", __func__, szimg);