/*
Global declarations.
*/
-#define MaxExceptions 32
-\f
-/*
- Global declarations.
-*/
static ErrorHandler
error_handler = DefaultErrorHandler;
*/
MagickExport void CatchException(ExceptionInfo *exception)
{
+ LinkedListInfo
+ *exceptions;
+
register const ExceptionInfo
*p;
if (exception->exceptions == (void *) NULL)
return;
LockSemaphoreInfo(exception->semaphore);
- ResetLinkedListIterator((LinkedListInfo *) exception->exceptions);
- p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
- exception->exceptions);
+ exceptions=(LinkedListInfo *) exception->exceptions;
+ ResetLinkedListIterator(exceptions);
+ p=(const ExceptionInfo *) GetNextValueInLinkedList(exceptions);
for (i=0; p != (const ExceptionInfo *) NULL; i++)
{
- if (i < MaxExceptions)
- {
- if ((p->severity >= WarningException) && (p->severity < ErrorException))
- MagickWarning(p->severity,p->reason,p->description);
- if ((p->severity >= ErrorException) &&
- (p->severity < FatalErrorException))
- MagickError(p->severity,p->reason,p->description);
- }
- else
- if (i == MaxExceptions)
- MagickError(ResourceLimitError,"too many exceptions",
- "exception processing is suspended");
+ if ((p->severity >= WarningException) && (p->severity < ErrorException))
+ MagickWarning(p->severity,p->reason,p->description);
+ if ((p->severity >= ErrorException) && (p->severity < FatalErrorException))
+ MagickError(p->severity,p->reason,p->description);
if (p->severity >= FatalErrorException)
MagickFatalError(p->severity,p->reason,p->description);
- p=(const ExceptionInfo *) GetNextValueInLinkedList((LinkedListInfo *)
- exception->exceptions);
+ p=(const ExceptionInfo *) GetNextValueInLinkedList(exceptions);
}
UnlockSemaphoreInfo(exception->semaphore);
ClearMagickException(exception);
MagickExport MagickBooleanType ThrowException(ExceptionInfo *exception,
const ExceptionType severity,const char *reason,const char *description)
{
+ LinkedListInfo
+ *exceptions;
+
register ExceptionInfo
*p;
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
LockSemaphoreInfo(exception->semaphore);
- p=(ExceptionInfo *) GetLastValueInLinkedList((LinkedListInfo *)
- exception->exceptions);
+ exceptions=(LinkedListInfo *) exception->exceptions;
+ if (GetNumberOfElementsInLinkedList(exceptions) > MagickMaxRecursionDepth)
+ {
+ UnlockSemaphoreInfo(exception->semaphore);
+ return(MagickTrue);
+ }
+ p=(ExceptionInfo *) GetLastValueInLinkedList(exceptions);
if ((p != (ExceptionInfo *) NULL) && (p->severity == severity) &&
(LocaleCompare(exception->reason,reason) == 0) &&
(LocaleCompare(exception->description,description) == 0))
if (description != (const char *) NULL)
p->description=ConstantString(description);
p->signature=MagickCoreSignature;
- (void) AppendValueToLinkedList((LinkedListInfo *) exception->exceptions,p);
+ (void) AppendValueToLinkedList(exceptions,p);
if (p->severity >= exception->severity)
{
exception->severity=p->severity;
exception->description=p->description;
}
UnlockSemaphoreInfo(exception->semaphore);
+ if (GetNumberOfElementsInLinkedList(exceptions) == MagickMaxRecursionDepth)
+ (void) ThrowMagickException(exception,GetMagickModule(),ResourceLimitError,
+ "TooManyExceptions","(exception processing is suspended)");
return(MagickTrue);
}
\f