From dcdce8fa68e285c3566cace148539f7d54f892fb Mon Sep 17 00:00:00 2001 From: Cristy Date: Sat, 24 Feb 2018 11:59:21 -0500 Subject: [PATCH] Avoid possible deadlock --- coders/caption.c | 4 ++++ coders/label.c | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/coders/caption.c b/coders/caption.c index 57c97fcdb..a953ed2cc 100644 --- a/coders/caption.c +++ b/coders/caption.c @@ -231,6 +231,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info, if (draw_info->gravity == UndefinedGravity) (void) CloneString(&draw_info->geometry,geometry); status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + break; width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5); height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); if ((image->columns != 0) && (image->rows != 0)) @@ -257,6 +259,8 @@ static Image *ReadCAPTIONImage(const ImageInfo *image_info, if (draw_info->gravity == UndefinedGravity) (void) CloneString(&draw_info->geometry,geometry); status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + break; width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5); height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); if ((image->columns != 0) && (image->rows != 0)) diff --git a/coders/label.c b/coders/label.c index 866beb8e2..e4b9b707d 100644 --- a/coders/label.c +++ b/coders/label.c @@ -150,16 +150,21 @@ static Image *ReadLABELImage(const ImageInfo *image_info, high, low; + ssize_t + n; + /* Auto fit text into bounding box. */ - for ( ; ; draw_info->pointsize*=2.0) + for (n=0; n < 32; n++, draw_info->pointsize*=2.0) { (void) FormatLocaleString(geometry,MagickPathExtent,"%+g%+g", -metrics.bounds.x1,metrics.ascent); if (draw_info->gravity == UndefinedGravity) (void) CloneString(&draw_info->geometry,geometry); status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + break; width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5); height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); if ((image->columns != 0) && (image->rows != 0)) @@ -181,6 +186,8 @@ static Image *ReadLABELImage(const ImageInfo *image_info, if (draw_info->gravity == UndefinedGravity) (void) CloneString(&draw_info->geometry,geometry); status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception); + if (status == MagickFalse) + break; width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5); height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5); if ((image->columns != 0) && (image->rows != 0)) -- 2.40.0