From: Cristy Date: Fri, 20 May 2016 00:40:12 +0000 (-0400) Subject: Eliminate small memory leak X-Git-Tag: 7.0.1-6~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=35fdb3f7c9ba4e3d9e95989f24bbe6960349d715;p=imagemagick Eliminate small memory leak --- diff --git a/MagickCore/distribute-cache.c b/MagickCore/distribute-cache.c index 53b822ff3..502e33f6b 100644 --- a/MagickCore/distribute-cache.c +++ b/MagickCore/distribute-cache.c @@ -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);