]> granicus.if.org Git - imagemagick/commitdiff
Eliminate small memory leak
authorCristy <urban-warrior@imagemagick.org>
Fri, 20 May 2016 00:40:12 +0000 (20:40 -0400)
committerCristy <urban-warrior@imagemagick.org>
Fri, 20 May 2016 00:40:12 +0000 (20:40 -0400)
MagickCore/distribute-cache.c

index 53b822ff397937af4f83f57085237dc299cbd9b1..502e33f6ba1455b03798363b26643c70cd06b131 100644 (file)
@@ -178,9 +178,7 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
 {
 #if defined(MAGICKCORE_HAVE_DISTRIBUTE_CACHE)
   char
-    service[MagickPathExtent];
-
-  const char
+    service[MagickPathExtent],
     *shared_secret;
 
   int
@@ -204,12 +202,14 @@ static int ConnectPixelCacheServer(const char *hostname,const int port,
   */
   *session_key=0;
   shared_secret=GetPolicyValue("shared-secret");
-  if (shared_secret == (const char *) NULL)
+  if (shared_secret == (char *) NULL)
     {
+      shared_secret=DestroyString(shared_secret);
       (void) ThrowMagickException(exception,GetMagickModule(),CacheError,
         "DistributedPixelCache","'%s'","shared secret expected");
       return(-1);
     }
+  shared_secret=DestroyString(shared_secret);
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
   NTInitializeWinsock(MagickTrue);
 #endif
@@ -767,7 +767,7 @@ static MagickBooleanType WriteDistributeCachePixels(SplayTreeInfo *registry,
 
 static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket)
 {
-  const char
+  char
     *shared_secret;
 
   ExceptionInfo
@@ -806,11 +806,12 @@ static HANDLER_RETURN_TYPE DistributePixelCacheClient(void *socket)
     Distributed pixel cache client.
   */
   shared_secret=GetPolicyValue("shared-secret");
-  if (shared_secret == (const char *) NULL)
+  if (shared_secret == (char *) NULL)
     ThrowFatalException(CacheFatalError,"shared secret expected");
   p=session;
   (void) CopyMagickString((char *) p,shared_secret,MagickPathExtent);
   p+=strlen(shared_secret);
+  shared_secret=DestroyString(shared_secret);
   random_info=AcquireRandomInfo();
   secret=GetRandomKey(random_info,DPCSessionKeyLength);
   (void) memcpy(p,GetStringInfoDatum(secret),DPCSessionKeyLength);