summaryrefslogtreecommitdiff
path: root/coders/txt.c
diff options
context:
space:
mode:
Diffstat (limited to 'coders/txt.c')
-rw-r--r--coders/txt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/coders/txt.c b/coders/txt.c
index 6432325..3c8ebd6 100644
--- a/coders/txt.c
+++ b/coders/txt.c
@@ -442,8 +442,10 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (!strncmp(p,"# ImageMagick pixel enumeration:",32))
{
- if (sscanf(p+32,"%u,%u,%u",&x_min,&y_curr,&x_max) == 3)
+ if (sscanf(p+32,"%u,%u,%u",&x_min,&y_curr,&x_max) == 3) /* x_max-x_min+1 x_max=0 x_min=1 */
{
+ if ((x_max == 0) || (x_max < x_min))
+ ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
if (strstr(p+32,",rgb")!=NULL)
{
x = x_min-1;
@@ -759,7 +761,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
/* A new line has been detected */
- if (y != y_curr)
+ if ((y != y_curr) && (x_max >= x_min))
{
q = SetImagePixels(image,x_min,y_curr,x_max-x_min+1,1);
if (q == (PixelPacket *)NULL)
@@ -1006,7 +1008,7 @@ static Image *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
rendered at a time via AnnotateImage().
*/
(void) ConcatenateString(&draw_info->text,text);
- (void) ConcatenateString(&draw_info->text,"\\n");
+ (void) ConcatenateString(&draw_info->text,"\n");
line_num++;
if (image->previous == (Image *) NULL)