From 76c635ceeebcb78ecd22807171c2e2c21c58e05f Mon Sep 17 00:00:00 2001 From: danblooomberg Date: Fri, 26 Apr 2024 12:27:19 -0700 Subject: [PATCH] Add check for number of corner points in ptaConvertToBox() * also for Issue 743, in pixWriteStreamBmp() check for colormap before referencing in DEBUG clause --- src/bmpio.c | 3 ++- src/boxfunc4.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bmpio.c b/src/bmpio.c index 5b09354df..6da03d98e 100644 --- a/src/bmpio.c +++ b/src/bmpio.c @@ -565,7 +565,8 @@ RGBA_QUAD *pquad; } #if DEBUG - {l_uint8 *pcmptr; + if (pixGetColormap(pix) != NULL) { + l_uint8 *pcmptr; pcmptr = (l_uint8 *)pixGetColormap(pix)->array; lept_stderr("Pix colormap[0] = %c%c%c%d\n", pcmptr[0], pcmptr[1], pcmptr[2], pcmptr[3]); diff --git a/src/boxfunc4.c b/src/boxfunc4.c index fc130f4a0..5f79e0af1 100644 --- a/src/boxfunc4.c +++ b/src/boxfunc4.c @@ -878,6 +878,8 @@ l_int32 n, x1, y1, x2, y2, x3, y3, x4, y4, x, y, xmax, ymax; if (!pta) return (BOX *)ERROR_PTR("pta not defined", __func__, NULL); n = ptaGetCount(pta); + if (n != 2 && n != 4) + return (BOX *)ERROR_PTR("n must be 2 or 4", __func__, NULL); ptaGetIPt(pta, 0, &x1, &y1); ptaGetIPt(pta, 1, &x2, &y2); if (n == 2)