From bec92f18b02d5e6093eb94e90a0353d4a5b26abe Mon Sep 17 00:00:00 2001 From: dirk Date: Sat, 24 Jan 2015 09:36:17 +0000 Subject: [PATCH] Replaced tag check with assert, the value should not be null. --- MagickCore/exception-private.h | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/MagickCore/exception-private.h b/MagickCore/exception-private.h index a10cfeeca..ba4437fbf 100644 --- a/MagickCore/exception-private.h +++ b/MagickCore/exception-private.h @@ -28,9 +28,10 @@ extern "C" { #define ThrowBinaryException(severity,tag,context) \ { \ + assert(tag != (const char *) NULL); \ if (image != (Image *) NULL) \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"`%s'",context); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "`%s'",context); \ return(MagickFalse); \ } #define ThrowFatalException(severity,tag) \ @@ -41,10 +42,11 @@ extern "C" { ExceptionInfo \ *exception; \ \ + assert(tag != (const char *) NULL); \ exception=AcquireExceptionInfo(); \ message=GetExceptionMessage(errno); \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"`%s'",message); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "`%s'",message); \ message=DestroyString(message); \ CatchException(exception); \ (void) DestroyExceptionInfo(exception); \ @@ -56,21 +58,24 @@ extern "C" { char \ *message; \ \ + assert(tag != (const char *) NULL); \ message=GetExceptionMessage(errno); \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"'%s': %s",context,message); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "'%s': %s",context,message); \ message=DestroyString(message); \ } #define ThrowImageException(severity,tag) \ { \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ + assert(tag != (const char *) NULL); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "`%s'",image->filename); \ return((Image *) NULL); \ } #define ThrowReaderException(severity,tag) \ { \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"`%s'",image_info->filename); \ + assert(tag != (const char *) NULL); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "`%s'",image_info->filename); \ if ((image) != (Image *) NULL) \ { \ (void) CloseBlob(image); \ @@ -80,8 +85,9 @@ extern "C" { } #define ThrowWriterException(severity,tag) \ { \ - (void) ThrowMagickException(exception,GetMagickModule(),severity, \ - tag == (const char *) NULL ? "unknown" : tag,"`%s'",image->filename); \ + assert(tag != (const char *) NULL); \ + (void) ThrowMagickException(exception,GetMagickModule(),severity,tag, \ + "`%s'",image->filename); \ if (image_info->adjoin != MagickFalse) \ while (image->previous != (Image *) NULL) \ image=image->previous; \ -- 2.50.1