Skip to content

Commit b18d864

Browse files
author
dirk
committed
Added missing checks for MAGICKCORE_ZERO_CONFIGURATION_SUPPORT.
1 parent c9f5cc8 commit b18d864

File tree

8 files changed

+187
-156
lines changed

8 files changed

+187
-156
lines changed

MagickCore/coder.c

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -322,38 +322,42 @@ static void *DestroyCoderNode(void *coder_info)
322322
static SplayTreeInfo *AcquireCoderCache(const char *filename,
323323
ExceptionInfo *exception)
324324
{
325-
const StringInfo
326-
*option;
327-
328-
LinkedListInfo
329-
*options;
330-
331325
MagickStatusType
332326
status;
333327

334328
register ssize_t
335329
i;
336330

337331
SplayTreeInfo
338-
*coder_cache;
332+
*cache;
339333

340334
/*
341335
Load external coder map.
342336
*/
343-
coder_cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
337+
cache=NewSplayTree(CompareSplayTreeString,RelinquishMagickMemory,
344338
DestroyCoderNode);
345-
if (coder_cache == (SplayTreeInfo *) NULL)
339+
if (cache == (SplayTreeInfo *) NULL)
346340
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
347341
status=MagickTrue;
348-
options=GetConfigureOptions(filename,exception);
349-
option=(const StringInfo *) GetNextValueInLinkedList(options);
350-
while (option != (const StringInfo *) NULL)
342+
#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
351343
{
352-
status&=LoadCoderCache(coder_cache,(const char *)
353-
GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
344+
const StringInfo
345+
*option;
346+
347+
LinkedListInfo
348+
*options;
349+
350+
options=GetConfigureOptions(filename,exception);
354351
option=(const StringInfo *) GetNextValueInLinkedList(options);
352+
while (option != (const StringInfo *) NULL)
353+
{
354+
status&=LoadCoderCache(cache,(const char *) GetStringInfoDatum(option),
355+
GetStringInfoPath(option),0,exception);
356+
option=(const StringInfo *) GetNextValueInLinkedList(options);
357+
}
358+
options=DestroyConfigureOptions(options);
355359
}
356-
options=DestroyConfigureOptions(options);
360+
#endif
357361
/*
358362
Load built-in coder map.
359363
*/
@@ -379,13 +383,13 @@ static SplayTreeInfo *AcquireCoderCache(const char *filename,
379383
coder_info->name=(char *) p->name;
380384
coder_info->exempt=MagickTrue;
381385
coder_info->signature=MagickCoreSignature;
382-
status&=AddValueToSplayTree(coder_cache,ConstantString(coder_info->magick),
386+
status&=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
383387
coder_info);
384388
if (status == MagickFalse)
385389
(void) ThrowMagickException(exception,GetMagickModule(),
386390
ResourceLimitError,"MemoryAllocationFailed","`%s'",coder_info->name);
387391
}
388-
return(coder_cache);
392+
return(cache);
389393
}
390394

391395
/*
@@ -788,9 +792,8 @@ MagickExport MagickBooleanType ListCoderInfo(FILE *file,
788792
%
789793
% The format of the LoadCoderCache coder is:
790794
%
791-
% MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
792-
% const char *xml,const char *filename,const size_t depth,
793-
% ExceptionInfo *exception)
795+
% MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
796+
% const char *filename,const size_t depth,ExceptionInfo *exception)
794797
%
795798
% A description of each parameter follows:
796799
%
@@ -803,9 +806,8 @@ MagickExport MagickBooleanType ListCoderInfo(FILE *file,
803806
% o exception: return any errors or warnings in this structure.
804807
%
805808
*/
806-
static MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
807-
const char *xml,const char *filename,const size_t depth,
808-
ExceptionInfo *exception)
809+
static MagickBooleanType LoadCoderCache(SplayTreeInfo *cache,const char *xml,
810+
const char *filename,const size_t depth,ExceptionInfo *exception)
809811
{
810812
char
811813
keyword[MagickPathExtent],
@@ -895,7 +897,7 @@ static MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
895897
file_xml=FileToXML(path,~0UL);
896898
if (file_xml != (char *) NULL)
897899
{
898-
status&=LoadCoderCache(coder_cache,file_xml,path,depth+1,
900+
status&=LoadCoderCache(cache,file_xml,path,depth+1,
899901
exception);
900902
file_xml=DestroyString(file_xml);
901903
}
@@ -922,8 +924,8 @@ static MagickBooleanType LoadCoderCache(SplayTreeInfo *coder_cache,
922924
continue;
923925
if (LocaleCompare(keyword,"/>") == 0)
924926
{
925-
status=AddValueToSplayTree(coder_cache,ConstantString(
926-
coder_info->magick),coder_info);
927+
status=AddValueToSplayTree(cache,ConstantString(coder_info->magick),
928+
coder_info);
927929
if (status == MagickFalse)
928930
(void) ThrowMagickException(exception,GetMagickModule(),
929931
ResourceLimitError,"MemoryAllocationFailed","`%s'",

MagickCore/color.c

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -828,12 +828,8 @@ static MagickBooleanType
828828
static LinkedListInfo *AcquireColorCache(const char *filename,
829829
ExceptionInfo *exception)
830830
{
831-
const StringInfo
832-
*option;
833-
834831
LinkedListInfo
835-
*color_cache,
836-
*options;
832+
*cache;
837833

838834
MagickStatusType
839835
status;
@@ -844,19 +840,29 @@ static LinkedListInfo *AcquireColorCache(const char *filename,
844840
/*
845841
Load external color map.
846842
*/
847-
color_cache=NewLinkedList(0);
848-
if (color_cache == (LinkedListInfo *) NULL)
843+
cache=NewLinkedList(0);
844+
if (cache == (LinkedListInfo *) NULL)
849845
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
850846
status=MagickTrue;
851-
options=GetConfigureOptions(filename,exception);
852-
option=(const StringInfo *) GetNextValueInLinkedList(options);
853-
while (option != (const StringInfo *) NULL)
847+
#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
854848
{
855-
status&=LoadColorCache(color_cache,(const char *)
856-
GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
849+
const StringInfo
850+
*option;
851+
852+
LinkedListInfo
853+
*options;
854+
855+
options=GetConfigureOptions(filename,exception);
857856
option=(const StringInfo *) GetNextValueInLinkedList(options);
857+
while (option != (const StringInfo *) NULL)
858+
{
859+
status&=LoadColorCache(cache,(const char *) GetStringInfoDatum(option),
860+
GetStringInfoPath(option),0,exception);
861+
option=(const StringInfo *) GetNextValueInLinkedList(options);
862+
}
863+
options=DestroyConfigureOptions(options);
858864
}
859-
options=DestroyConfigureOptions(options);
865+
#endif
860866
/*
861867
Load built-in color map.
862868
*/
@@ -887,15 +893,14 @@ static LinkedListInfo *AcquireColorCache(const char *filename,
887893
color_info->compliance=(ComplianceType) p->compliance;
888894
color_info->exempt=MagickTrue;
889895
color_info->signature=MagickCoreSignature;
890-
status&=AppendValueToLinkedList(color_cache,color_info);
896+
status&=AppendValueToLinkedList(cache,color_info);
891897
if (status == MagickFalse)
892898
(void) ThrowMagickException(exception,GetMagickModule(),
893899
ResourceLimitError,"MemoryAllocationFailed","`%s'",color_info->name);
894900
}
895-
return(color_cache);
901+
return(cache);
896902
}
897-
898-
903+
899904
/*
900905
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
901906
% %
@@ -1976,9 +1981,8 @@ MagickExport MagickBooleanType ListColorInfo(FILE *file,
19761981
%
19771982
% The format of the LoadColorCache method is:
19781983
%
1979-
% MagickBooleanType LoadColorCache(LinkedListInfo *color_cache,
1980-
% const char *xml,const char *filename,const size_t depth,
1981-
% ExceptionInfo *exception)
1984+
% MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
1985+
% const char *filename,const size_t depth,ExceptionInfo *exception)
19821986
%
19831987
% A description of each parameter follows:
19841988
%
@@ -1991,9 +1995,8 @@ MagickExport MagickBooleanType ListColorInfo(FILE *file,
19911995
% o exception: return any errors or warnings in this structure.
19921996
%
19931997
*/
1994-
static MagickBooleanType LoadColorCache(LinkedListInfo *color_cache,
1995-
const char *xml,const char *filename,const size_t depth,
1996-
ExceptionInfo *exception)
1998+
static MagickBooleanType LoadColorCache(LinkedListInfo *cache,const char *xml,
1999+
const char *filename,const size_t depth,ExceptionInfo *exception)
19972000
{
19982001
char
19992002
keyword[MagickPathExtent],
@@ -2083,7 +2086,7 @@ static MagickBooleanType LoadColorCache(LinkedListInfo *color_cache,
20832086
file_xml=FileToXML(path,~0UL);
20842087
if (file_xml != (char *) NULL)
20852088
{
2086-
status&=LoadColorCache(color_cache,file_xml,path,depth+1,
2089+
status&=LoadColorCache(cache,file_xml,path,depth+1,
20872090
exception);
20882091
file_xml=DestroyString(file_xml);
20892092
}
@@ -2110,7 +2113,7 @@ static MagickBooleanType LoadColorCache(LinkedListInfo *color_cache,
21102113
continue;
21112114
if (LocaleCompare(keyword,"/>") == 0)
21122115
{
2113-
status=AppendValueToLinkedList(color_cache,color_info);
2116+
status=AppendValueToLinkedList(cache,color_info);
21142117
if (status == MagickFalse)
21152118
(void) ThrowMagickException(exception,GetMagickModule(),
21162119
ResourceLimitError,"MemoryAllocationFailed","`%s'",

MagickCore/configure.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,8 @@ static MagickBooleanType
150150
static LinkedListInfo *AcquireConfigureCache(const char *filename,
151151
ExceptionInfo *exception)
152152
{
153-
const StringInfo
154-
*option;
155-
156153
LinkedListInfo
157-
*configure_cache,
158-
*options;
154+
*cache;
159155

160156
MagickStatusType
161157
status;
@@ -166,19 +162,29 @@ static LinkedListInfo *AcquireConfigureCache(const char *filename,
166162
/*
167163
Load external configure map.
168164
*/
169-
configure_cache=NewLinkedList(0);
170-
if (configure_cache == (LinkedListInfo *) NULL)
165+
cache=NewLinkedList(0);
166+
if (cache == (LinkedListInfo *) NULL)
171167
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
172168
status=MagickTrue;
173-
options=GetConfigureOptions(filename,exception);
174-
option=(const StringInfo *) GetNextValueInLinkedList(options);
175-
while (option != (const StringInfo *) NULL)
169+
#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
176170
{
177-
status&=LoadConfigureCache(configure_cache,(const char *)
178-
GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
171+
const StringInfo
172+
*option;
173+
174+
LinkedListInfo
175+
*options;
176+
177+
options=GetConfigureOptions(filename,exception);
179178
option=(const StringInfo *) GetNextValueInLinkedList(options);
179+
while (option != (const StringInfo *) NULL)
180+
{
181+
status&=LoadConfigureCache(cache,(const char *)
182+
GetStringInfoDatum(option),GetStringInfoPath(option),0,exception);
183+
option=(const StringInfo *) GetNextValueInLinkedList(options);
184+
}
185+
options=DestroyConfigureOptions(options);
180186
}
181-
options=DestroyConfigureOptions(options);
187+
#endif
182188
/*
183189
Load built-in configure map.
184190
*/
@@ -205,13 +211,13 @@ static LinkedListInfo *AcquireConfigureCache(const char *filename,
205211
configure_info->value=(char *) p->value;
206212
configure_info->exempt=MagickTrue;
207213
configure_info->signature=MagickCoreSignature;
208-
status&=AppendValueToLinkedList(configure_cache,configure_info);
214+
status&=AppendValueToLinkedList(cache,configure_info);
209215
if (status == MagickFalse)
210216
(void) ThrowMagickException(exception,GetMagickModule(),
211217
ResourceLimitError,"MemoryAllocationFailed","`%s'",
212218
configure_info->name);
213219
}
214-
return(configure_cache);
220+
return(cache);
215221
}
216222

217223
/*
@@ -1121,7 +1127,7 @@ MagickExport MagickBooleanType ListConfigureInfo(FILE *file,
11211127
%
11221128
% The format of the LoadConfigureCache method is:
11231129
%
1124-
% MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache,
1130+
% MagickBooleanType LoadConfigureCache(LinkedListInfo *cache,
11251131
% const char *xml,const char *filename,const size_t depth,
11261132
% ExceptionInfo *exception)
11271133
%
@@ -1136,7 +1142,7 @@ MagickExport MagickBooleanType ListConfigureInfo(FILE *file,
11361142
% o exception: return any errors or warnings in this structure.
11371143
%
11381144
*/
1139-
static MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache,
1145+
static MagickBooleanType LoadConfigureCache(LinkedListInfo *cache,
11401146
const char *xml,const char *filename,const size_t depth,
11411147
ExceptionInfo *exception)
11421148
{
@@ -1226,8 +1232,8 @@ static MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache,
12261232
file_xml=FileToXML(path,~0UL);
12271233
if (file_xml != (char *) NULL)
12281234
{
1229-
status&=LoadConfigureCache(configure_cache,file_xml,path,
1230-
depth+1,exception);
1235+
status&=LoadConfigureCache(cache,file_xml,path,depth+1,
1236+
exception);
12311237
file_xml=DestroyString(file_xml);
12321238
}
12331239
}
@@ -1254,7 +1260,7 @@ static MagickBooleanType LoadConfigureCache(LinkedListInfo *configure_cache,
12541260
continue;
12551261
if (LocaleCompare(keyword,"/>") == 0)
12561262
{
1257-
status=AppendValueToLinkedList(configure_cache,configure_info);
1263+
status=AppendValueToLinkedList(cache,configure_info);
12581264
if (status == MagickFalse)
12591265
(void) ThrowMagickException(exception,GetMagickModule(),
12601266
ResourceLimitError,"MemoryAllocationFailed","`%s'",

0 commit comments

Comments
 (0)