+2023-04-15 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
+
+ * magick/attribute.c (SetImageAttribute): Eliminate memory leak
+ when handling attribute with key "EXIF:Orientation". (SourceForge
+ issue #707 "memory leaks in gm").
+
2023-04-08 Bob Friesenhahn <bfriesen@simple.dallas.tx.us>
* coders/mpc.c (ReadMPCImage): If an attribute appears multiple
MagickPassFail
status;
+ status = SetImageAttribute(image,key,value);
+
if (GetImageAttribute(image,key) == (const ImageAttribute *) NULL)
status = SetImageAttribute(image,key,value);
else
register ImageAttribute
*p;
- int
- orientation;
-
/*
Initialize new attribute.
*/
if (LocaleCompare(attribute->key,"EXIF:Orientation") == 0)
{
+ int
+ orientation = 0;
+
/*
Special handling for EXIF orientation tag.
If new value differs from existing value,
is valid. Don't append new value to existing value,
replace it instead.
*/
- orientation = MagickAtoI(value);
- if (orientation > 0 || orientation <= (int)LeftBottomOrientation)
- SetEXIFOrientation(image, orientation);
-
- /* Replace current attribute with new one */
- attribute->next = p->next;
- if (p->previous == (ImageAttribute *) NULL)
- image->attributes=attribute;
- else
- p->previous->next = attribute;
- DestroyImageAttribute(p);
+ if ((MagickAtoIChk(value, &orientation) == MagickPass) &&
+ (orientation > 0 || orientation <= (int)LeftBottomOrientation))
+ {
+ SetEXIFOrientation(image, orientation);
+ }
+ /* Assign changed value to attribute in list */
+ if (LocaleCompare(p->value, attribute->value) != 0)
+ {
+ MagickFreeMemory(p->value);
+ p->value=attribute->value;
+ attribute->value = (char *) NULL;
+ }
+ DestroyImageAttribute(attribute);
return(MagickPass);
}
else
/*
Extend existing text string. This functionality is deprecated!
*/
+ fprintf(stderr,
+ "SetImageAttribute: Extending attribute value text is deprecated! (key=\"%s\")\n",
+ attribute->key);
min_l=p->length+attribute->length+1;
for (realloc_l=2; realloc_l <= min_l; realloc_l *= 2)
{ /* nada */};
</div>
<div class="document">
+<p>2023-04-15 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p>
+<blockquote>
+<ul class="simple">
+<li><p>magick/attribute.c (SetImageAttribute): Eliminate memory leak
+when handling attribute with key "EXIF:Orientation". (SourceForge
+issue #707 "memory leaks in gm").</p></li>
+</ul>
+</blockquote>
<p>2023-04-08 Bob Friesenhahn <<a class="reference external" href="mailto:bfriesen%40simple.dallas.tx.us">bfriesen<span>@</span>simple<span>.</span>dallas<span>.</span>tx<span>.</span>us</a>></p>
<blockquote>
<ul class="simple">