Skip to content

Commit

Permalink
Set the double* arguments to NAN in case of a failure to avoid uninit…
Browse files Browse the repository at this point in the history
…ialized values.
  • Loading branch information
dlemstra committed May 12, 2024
1 parent be22d59 commit e2f0f4c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions MagickCore/statistic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,10 @@ MagickExport MagickBooleanType GetImageEntropy(const Image *image,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
channel_statistics=GetImageStatistics(image,exception);
if (channel_statistics == (ChannelStatistics *) NULL)
return(MagickFalse);
{
*entropy=NAN;
return(MagickFalse);
}
*entropy=channel_statistics[CompositePixelChannel].entropy;
channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
channel_statistics);
Expand Down Expand Up @@ -1302,7 +1305,11 @@ MagickExport MagickBooleanType GetImageKurtosis(const Image *image,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
channel_statistics=GetImageStatistics(image,exception);
if (channel_statistics == (ChannelStatistics *) NULL)
return(MagickFalse);
{
*kurtosis=NAN;
*skewness=NAN;
return(MagickFalse);
}
*kurtosis=channel_statistics[CompositePixelChannel].kurtosis;
*skewness=channel_statistics[CompositePixelChannel].skewness;
channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
Expand Down Expand Up @@ -1404,7 +1411,10 @@ MagickExport MagickBooleanType GetImageMedian(const Image *image,double *median,
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
channel_statistics=GetImageStatistics(image,exception);
if (channel_statistics == (ChannelStatistics *) NULL)
return(MagickFalse);
{
*median=NAN;
return(MagickFalse);
}
*median=channel_statistics[CompositePixelChannel].median;
channel_statistics=(ChannelStatistics *) RelinquishMagickMemory(
channel_statistics);
Expand Down

0 comments on commit e2f0f4c

Please sign in to comment.