From 0fd2047fad6ae6d51a53035df3c95277dbc0b621 Mon Sep 17 00:00:00 2001 From: iabdalkader Date: Sat, 22 Mar 2014 19:40:25 +0200 Subject: [PATCH] Add check for array length --- src/img/blob.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/img/blob.c b/src/img/blob.c index 09ad78ac1..196a723b4 100644 --- a/src/img/blob.c +++ b/src/img/blob.c @@ -16,13 +16,18 @@ array_t *imlib_count_blobs(struct image *image) for (int x=0; xw; x++) { int i=y*image->w+x; if (pixels[i]) { - /* new blob */ + /* new blob */ rectangle_t *blob = rectangle_alloc(image->w, image->h, 0, 0); array_push_back(blobs, blob); /* flood fill */ point_t *p=point_alloc(x, y); while(p != NULL) { + if (array_length(points) > 500) { + xfree(p); + goto done; + } + /* add point to blob */ if (p->x < blob->x) { blob->x = p->x; @@ -71,6 +76,7 @@ array_t *imlib_count_blobs(struct image *image) } } +done: for (int i=0; iw < 10) { /* blob too small */