mirror of
https://github.com/ImageMagick/ImageMagick.git
synced 2026-05-31 11:18:42 +02:00
Fix unsound free of uninitialized pointers in GetImageFeatures error path (#8724)
The first error branch in GetImageFeatures freed Q[i] and cooccurrence[i] before those array elements had been initialized (they are populated by the subsequent for loop). Remove the inner free loops. The outer Q and cooccurrence arrays are still released; the second error branch already handles partially-initialized arrays correctly and is unchanged.
This commit is contained in:
+3
-12
@@ -790,11 +790,7 @@ MagickExport ChannelFeatures *GetImageFeatures(const Image *image,
|
||||
(sum == (ChannelStatistics *) NULL))
|
||||
{
|
||||
if (Q != (ChannelStatistics **) NULL)
|
||||
{
|
||||
for (i=0; i < (ssize_t) number_grays; i++)
|
||||
Q[i]=(ChannelStatistics *) RelinquishMagickMemory(Q[i]);
|
||||
Q=(ChannelStatistics **) RelinquishMagickMemory(Q);
|
||||
}
|
||||
Q=(ChannelStatistics **) RelinquishMagickMemory(Q);
|
||||
if (sum != (ChannelStatistics *) NULL)
|
||||
sum=(ChannelStatistics *) RelinquishMagickMemory(sum);
|
||||
if (density_y != (ChannelStatistics *) NULL)
|
||||
@@ -804,13 +800,8 @@ MagickExport ChannelFeatures *GetImageFeatures(const Image *image,
|
||||
if (density_x != (ChannelStatistics *) NULL)
|
||||
density_x=(ChannelStatistics *) RelinquishMagickMemory(density_x);
|
||||
if (cooccurrence != (ChannelStatistics **) NULL)
|
||||
{
|
||||
for (i=0; i < (ssize_t) number_grays; i++)
|
||||
cooccurrence[i]=(ChannelStatistics *)
|
||||
RelinquishMagickMemory(cooccurrence[i]);
|
||||
cooccurrence=(ChannelStatistics **) RelinquishMagickMemory(
|
||||
cooccurrence);
|
||||
}
|
||||
cooccurrence=(ChannelStatistics **) RelinquishMagickMemory(
|
||||
cooccurrence);
|
||||
grays=(PixelPacket *) RelinquishMagickMemory(grays);
|
||||
channel_features=(ChannelFeatures *) RelinquishMagickMemory(
|
||||
channel_features);
|
||||
|
||||
Reference in New Issue
Block a user