]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 20:54:39 +0000 (16:54 -0400)
committerCristy <urban-warrior@imagemagick.org>
Wed, 26 Apr 2017 20:54:39 +0000 (16:54 -0400)
coders/dcm.c

index 31352d576ce6564e34ea67027d37f850eab941f4..c5446e1a685c83d493e3263865646cfb99fbea07 100644 (file)
@@ -2967,7 +2967,7 @@ static MagickBooleanType ReadDCMPixels(Image *image,DCMInfo *info,
 
 static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
 {
-#define ThrowDCMReaderException(exception,message) \
+#define ThrowDCMException(exception,message) \
 { \
   if (data != (unsigned char *) NULL) \
     data=(unsigned char *) RelinquishMagickMemory(data); \
@@ -3058,17 +3058,17 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
   data=(unsigned char *) NULL;
   stream_info=(DCMStreamInfo *) AcquireMagickMemory(sizeof(*stream_info));
   if (stream_info == (DCMStreamInfo *) NULL)
-    ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+    ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
   (void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
   count=ReadBlob(image,128,(unsigned char *) magick);
   if (count != 128)
-    ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+    ThrowDCMException(CorruptImageError,"ImproperImageHeader");
   count=ReadBlob(image,4,(unsigned char *) magick);
   if ((count != 4) || (LocaleNCompare(magick,"DICM",4) != 0))
     {
       offset=SeekBlob(image,0L,SEEK_SET);
       if (offset < 0)
-        ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+        ThrowDCMException(CorruptImageError,"ImproperImageHeader");
     }
   /*
     Read DCM Medical image.
@@ -3127,7 +3127,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
     (void) CopyMagickString(implicit_vr,dicom_info[i].vr,MagickPathExtent);
     count=ReadBlob(image,2,(unsigned char *) explicit_vr);
     if (count != 2)
-      ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+      ThrowDCMException(CorruptImageError,"ImproperImageHeader");
     /*
       Check for "explicitness", but meta-file headers always explicit.
     */
@@ -3143,7 +3143,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       {
         offset=SeekBlob(image,(MagickOffsetType) -2,SEEK_CUR);
         if (offset < 0)
-          ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+          ThrowDCMException(CorruptImageError,"ImproperImageHeader");
         quantum=4;
       }
     else
@@ -3258,8 +3258,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                 data=(unsigned char *) AcquireQuantumMemory(length+1,quantum*
                   sizeof(*data));
               if (data == (unsigned char *) NULL)
-                ThrowDCMReaderException(ResourceLimitError,
-                  "MemoryAllocationFailed");
+                ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
               count=ReadBlob(image,(size_t) quantum*length,data);
               if (count != (ssize_t) (quantum*length))
                 {
@@ -3267,7 +3266,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     (void) FormatLocaleFile(stdout,"count=%d quantum=%d "
                       "length=%d group=%d\n",(int) count,(int) quantum,(int)
                       length,(int) group);
-                   ThrowDCMReaderException(CorruptImageError,
+                   ThrowDCMException(CorruptImageError,
                      "InsufficientImageDataInFile");
                 }
               data[length*quantum]='\0';
@@ -3339,7 +3338,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
                     count=(ssize_t) sscanf(transfer_syntax+17,".%d.%d",&type,
                       &subtype);
                     if (count < 1)
-                      ThrowDCMReaderException(CorruptImageError,
+                      ThrowDCMException(CorruptImageError,
                         "ImproperImageHeader");
                   }
                 switch (type)
@@ -3451,7 +3450,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               info.bytes_per_pixel=2;
             info.depth=info.bits_allocated;
             if (info.depth > 32)
-              ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+              ThrowDCMException(CorruptImageError,"ImproperImageHeader");
             info.max_value=(1UL << info.bits_allocated)-1;
             image->depth=info.depth;
             break;
@@ -3467,7 +3466,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               info.bytes_per_pixel=2;
             info.depth=info.significant_bits;
             if (info.depth > 32)
-              ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+              ThrowDCMException(CorruptImageError,"ImproperImageHeader");
             info.max_value=(1UL << info.significant_bits)-1;
             info.mask=(size_t) GetQuantumRange(info.significant_bits);
             image->depth=info.depth;
@@ -3537,8 +3536,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             graymap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*graymap));
             if (graymap == (int *) NULL)
-              ThrowDCMReaderException(ResourceLimitError,
-                "MemoryAllocationFailed");
+              ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
             for (i=0; i < (ssize_t) colors; i++)
               if (info.bytes_per_pixel == 1)
                 graymap[i]=(int) data[i];
@@ -3561,8 +3559,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             redmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*redmap));
             if (redmap == (int *) NULL)
-              ThrowDCMReaderException(ResourceLimitError,
-                "MemoryAllocationFailed");
+              ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
             for (i=0; i < (ssize_t) colors; i++)
             {
@@ -3590,8 +3587,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             greenmap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*greenmap));
             if (greenmap == (int *) NULL)
-              ThrowDCMReaderException(ResourceLimitError,
-                "MemoryAllocationFailed");
+              ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
             for (i=0; i < (ssize_t) colors; i++)
             {
@@ -3619,8 +3615,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             bluemap=(int *) AcquireQuantumMemory((size_t) colors,
               sizeof(*bluemap));
             if (bluemap == (int *) NULL)
-              ThrowDCMReaderException(ResourceLimitError,
-                "MemoryAllocationFailed");
+              ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
             p=data;
             for (i=0; i < (ssize_t) colors; i++)
             {
@@ -3723,7 +3718,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       }
   }
   if ((width == 0) || (height == 0))
-    ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+    ThrowDCMException(CorruptImageError,"ImproperImageHeader");
   image->columns=(size_t) width;
   image->rows=(size_t) height;
   if (info.signed_data == 0xffff)
@@ -3763,8 +3758,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           stream_info->offsets=(ssize_t *) AcquireQuantumMemory(
             stream_info->offset_count,sizeof(*stream_info->offsets));
           if (stream_info->offsets == (ssize_t *) NULL)
-            ThrowDCMReaderException(ResourceLimitError,
-              "MemoryAllocationFailed");
+            ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
           for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image);
           offset=TellBlob(image);
@@ -3802,7 +3796,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (tag == 0xFFFEE0DD)
           break; /* sequence delimiter tag */
         if (tag != 0xFFFEE000)
-          ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+          ThrowDCMException(CorruptImageError,"ImproperImageHeader");
         file=(FILE *) NULL;
         unique_file=AcquireUniqueFileResource(filename);
         if (unique_file != -1)
@@ -3864,7 +3858,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       length=(size_t) (GetQuantumRange(info.depth)+1);
       info.scale=(Quantum *) AcquireQuantumMemory(length,sizeof(*info.scale));
       if (info.scale == (Quantum *) NULL)
-        ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+        ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
       range=GetQuantumRange(info.depth);
       for (i=0; i <= (ssize_t) GetQuantumRange(info.depth); i++)
         info.scale[i]=ScaleAnyToQuantum((size_t) i,range);
@@ -3894,7 +3888,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           stream_info->offsets=(ssize_t *) AcquireQuantumMemory(
             stream_info->offset_count,sizeof(*stream_info->offsets));
           if (stream_info->offsets == (ssize_t *) NULL)
-            ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+            ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
           for (i=0; i < (ssize_t) stream_info->offset_count; i++)
             stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image);
           offset=TellBlob(image)+8;
@@ -3926,7 +3920,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         if (colors == 0)
           colors=one << info.depth;
         if (AcquireImageColormap(image,one << info.depth,exception) == MagickFalse)
-          ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+          ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
         if (redmap != (int *) NULL)
           for (i=0; i < (ssize_t) colors; i++)
           {
@@ -3980,7 +3974,7 @@ static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
         stream_info->remaining=(size_t) ReadBlobLSBLong(image);
         if ((tag != 0xFFFEE000) || (stream_info->remaining <= 64) ||
             (EOFBlob(image) != MagickFalse))
-          ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+          ThrowDCMException(CorruptImageError,"ImproperImageHeader");
         stream_info->count=0;
         stream_info->segment_count=ReadBlobLSBLong(image);
         for (i=0; i < 15; i++)