]> granicus.if.org Git - imagemagick/commitdiff
resolve several null pointer dereferences
authorIlya Shipitsin <chipitsine@gmail.com>
Thu, 30 Aug 2018 10:16:20 +0000 (15:16 +0500)
committerDirk Lemstra <dirk@lemstra.org>
Thu, 30 Aug 2018 10:30:11 +0000 (12:30 +0200)
found by cppcheck

[MagickCore/draw.c:881] -> [MagickCore/draw.c:879]: (warning) Either the condition 'draw_info!=(DrawInfo*)NULL' is redundant or there is possible null pointer dereference: draw_info.
[MagickCore/fx.c:3966] -> [MagickCore/fx.c:3964]: (warning) Either the condition 'image!=(Image*)NULL' is redundant or there is possible null pointer dereference: image.
[MagickCore/fx.c:5009] -> [MagickCore/fx.c:5006]: (warning) Either the condition 'right_image!=(const Image*)NULL' is redundant or there is possible null pointer dereference: right_image.
[MagickCore/montage.c:168] -> [MagickCore/montage.c:166]: (warning) Either the condition 'montage_info!=(MontageInfo*)NULL' is redundant or there is possible null pointer dereference: montage_info.
[MagickCore/montage.c:416] -> [MagickCore/montage.c:415]: (warning) Either the condition 'master_list==(Image**)NULL' is redundant or there is possible null pointer dereference: image_list.
[MagickCore/nt-base.c:1792] -> [MagickCore/nt-base.c:1797]: (warning) Either the condition 'entry!=(DIR*)NULL' is redundant or there is possible null pointer dereference: entry.
[MagickWand/drawing-wand.c:177] -> [MagickWand/drawing-wand.c:175]: (warning) Either the condition 'wand!=(DrawingWand*)NULL' is redundant or there is possible null pointer dereference: wand.
[MagickWand/drawing-wand.c:4540] -> [MagickWand/drawing-wand.c:4538]: (warning) Either the condition 'wand!=(DrawingWand*)NULL' is redundant or there is possible null pointer dereference: wand.
[MagickWand/drawing-wand.c:4682] -> [MagickWand/drawing-wand.c:4680]: (warning) Either the condition 'wand!=(DrawingWand*)NULL' is redundant or there is possible null pointer dereference: wand.
[coders/msl.c:575] -> [coders/msl.c:555]: (warning) Either the condition 'image==(Image*)NULL' is redundant or there is possible null pointer dereference: image.

MagickCore/draw.c
MagickCore/fx.c
MagickCore/montage.c
MagickCore/nt-base.c
coders/msl.c

index 297407bc406f0bb8e9557daa292239f5577b2f59..b6e5a8fd417397e5f707fe432b566a0a7c76be69 100644 (file)
@@ -876,9 +876,9 @@ static PathInfo *ConvertPrimitiveToPath(const PrimitiveInfo *primitive_info)
 */
 MagickExport DrawInfo *DestroyDrawInfo(DrawInfo *draw_info)
 {
+  assert(draw_info != (DrawInfo *) NULL);
   if (draw_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  assert(draw_info != (DrawInfo *) NULL);
   assert(draw_info->signature == MagickCoreSignature);
   if (draw_info->primitive != (char *) NULL)
     draw_info->primitive=DestroyString(draw_info->primitive);
index 12dcc0996efba43ac7813f8be337ad2018e62728..bcf27f8523f011197e5addb00cd8ea4a1483f0b1 100644 (file)
@@ -3961,9 +3961,9 @@ MagickExport MagickBooleanType PlasmaImage(Image *image,
   RandomInfo
     *random_info;
 
+  assert(image != (Image *) NULL);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  assert(image != (Image *) NULL);
   assert(image->signature == MagickCoreSignature);
   if (image->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
@@ -5006,7 +5006,6 @@ MagickExport Image *StereoAnaglyphImage(const Image *left_image,
   assert(right_image->signature == MagickCoreSignature);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickCoreSignature);
-  assert(right_image != (const Image *) NULL);
   image=left_image;
   if ((left_image->columns != right_image->columns) ||
       (left_image->rows != right_image->rows))
index a18bca35ad067c47b00363cc57e0d3d05ec95322..fd83546c65c51361660fc15a475817f344ebb095 100644 (file)
@@ -163,9 +163,9 @@ MagickExport MontageInfo *CloneMontageInfo(const ImageInfo *image_info,
 */
 MagickExport MontageInfo *DestroyMontageInfo(MontageInfo *montage_info)
 {
+  assert(montage_info != (MontageInfo *) NULL);
   if (montage_info->debug != MagickFalse)
     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
-  assert(montage_info != (MontageInfo *) NULL);
   assert(montage_info->signature == MagickCoreSignature);
   if (montage_info->geometry != (char *) NULL)
     montage_info->geometry=(char *)
@@ -411,10 +411,10 @@ MagickExport Image *MontageImageList(const ImageInfo *image_info,
   assert(exception->signature == MagickCoreSignature);
   number_images=GetImageListLength(images);
   master_list=ImageListToArray(images,exception);
-  image_list=master_list;
-  image=image_list[0];
   if (master_list == (Image **) NULL)
     ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
+  image_list=master_list;
+  image=image_list[0];
   thumbnail=NewImageList();
   for (i=0; i < (ssize_t) number_images; i++)
   {
index ae856000726c5a1b44d5bb634fde022ca55c70b9..ca785a06cc765c094002dc999754d294f22a100b 100644 (file)
@@ -1789,11 +1789,8 @@ MagickPrivate DIR *NTOpenDirectory(const char *path)
         MagickPathExtent-wcslen(file_specification)-1) == (wchar_t*) NULL)
     return((DIR *) NULL);
   entry=(DIR *) AcquireCriticalMemory(sizeof(DIR));
-  if (entry != (DIR *) NULL)
-    {
-      entry->firsttime=TRUE;
-      entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData);
-    }
+  entry->firsttime=TRUE;
+  entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData);
   if (entry->hSearch == INVALID_HANDLE_VALUE)
     {
       if(wcsncat(file_specification,L"*.*",
index 0ecfcf1ae65355c25205215ae484b9d2fdd09d1a..dee0526ce8ab84f5c409fcd7f62d5a924440c30f 100644 (file)
@@ -552,7 +552,8 @@ static void MSLPushImage(MSLInfo *msl_info,Image *image)
   ssize_t
     n;
 
-  (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
+  if (image != (Image *) NULL)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
   assert(msl_info != (MSLInfo *) NULL);
   msl_info->n++;
   n=msl_info->n;