]> granicus.if.org Git - imagemagick/commitdiff
Moved assertion and added not null check (Github: #33)
authordirk <dirk@git.imagemagick.org>
Tue, 22 Sep 2015 05:18:34 +0000 (07:18 +0200)
committerdirk <dirk@git.imagemagick.org>
Tue, 22 Sep 2015 05:18:34 +0000 (07:18 +0200)
coders/dot.c

index b03bf28a9e55f9f9277306f4477a83d2d29c2b7e..ca477b54c550892f9837b69b68a7cbb07d6ce7c0 100644 (file)
@@ -125,6 +125,7 @@ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       image_info->filename);
   assert(exception != (ExceptionInfo *) NULL);
   assert(exception->signature == MagickCoreSignature);
+  assert(graphic_context != (GVC_t *) NULL);
   image=AcquireImage(image_info,exception);
   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
   if (status == MagickFalse)
@@ -146,7 +147,6 @@ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception)
       return ((Image *) NULL);
     }
   option=GetImageOption(image_info,"dot:layout-engine");
-  assert(graphic_context != (GVC_t *) NULL);
   if (option == (const char *) NULL)
     gvLayout(graphic_context,graph,(char *) "dot");
   else
@@ -236,7 +236,10 @@ ModuleExport void UnregisterDOTImage(void)
   (void) UnregisterMagickInfo("GV");
   (void) UnregisterMagickInfo("DOT");
 #if defined(MAGICKCORE_GVC_DELEGATE)
-  gvFreeContext(graphic_context);
-  graphic_context=(GVC_t *) NULL;
+  if (graphic_context != (GVC_t *) NULL)
+    {
+      gvFreeContext(graphic_context);
+      graphic_context=(GVC_t *) NULL;
+    }
 #endif
 }