Package: imagemagick
Version: 6:6.2.4.5-0.6.kmr1
Severity: important

I've sent a bug to the imagemagick developers as included
below. The developers confirmed the bug and fixed the bug in
ImageMagick 6.2.6 beta1. 

Kevin


------- Original bug report --------

[1]
I believe that DestroyStringInfo is being incorrectly called after
GetImageProfile. I've posted a test case below[1]. It appears that
calling DestroyStringInfo on the profile and then destroying the image
causes an error[2]. I've also posted an example using C that has the
same error result that I believe mirrors what the PerlMagick interface
does.[3]

Looking more closely at GetImageProfile in magick/profile.c, the
string value comes from GetValueFromSplayTree which returns
splay_info->root->value. It appears to be that this StringInfo is
getting freed once my DestroyStringInfo and then again by DestroyImage.

As someone fairly new to the imagemagick source code, I worked around
this by remove the DestroyStringInfo calls that occur after
GetImageProfile in PerlMagick/Magick.xs. With that change, the test
case in [1] now works.  However, that may not be the most robust fix.

I appreciate the thoughts of the ImageMagick developers if I'm on the
right track thinking about this or if I'm misunderstanding how to get
ICC profiles using ImageMagick.

[1] test-icc.pl
#!/usr/bin/perl
use Image::Magick;
use Data::Dumper;

my $fname = '/home/hs/1.jpg';
my $image = Image::Magick->new;
my $res = $image->Read('image-with-icc.jpg');
die "$res" if "$res";

$image->Get('icc');
print "about to undef image\n";
undef $image;
print "done\n";

 
[2]
[EMAIL PROTECTED]:~> ./test-icc.pl
about to undef image
perl: magick/string.c:658: DestroyStringInfo: Assertion
`string_info->signature == 0xabacadabUL' failed.


[3] 
#include <stdio.h>
#include <stdlib.h>
#include <magick/ImageMagick.h>
#include <string.h>

int main(int c, char**argv) 
{
  ExceptionInfo exception;
  Image *image, *images, *thumbnails, *resize_image;
  ImageInfo *image_info;
  
  InitializeMagick(*argv);
  GetExceptionInfo(&exception);
  image_info=CloneImageInfo((ImageInfo *) NULL);
  (void) strcpy(image_info->filename,"image-icc.jpg");
  images=ReadImage(image_info,&exception);
  if (exception.severity != UndefinedException)
    CatchException(&exception);
  if (images == (Image *) NULL) {
    printf("can't read image\n");
    exit(1);
  }

  while ((image=RemoveFirstImageFromList(&images)) != (Image *) NULL)
    {
      StringInfo *si = GetImageProfile(image,"icc");
      if (si != (StringInfo *) NULL) {
        printf("icc len: %d\n",si->length);
        DestroyStringInfo (si);
        DestroyImage(image); // Errors here 
      }
    }

 image_info=DestroyImageInfo(image_info);
 DestroyExceptionInfo(&exception);
 DestroyMagick();  
 printf("done\n");
 return(0);
}
_______________________________________________
Magick-bugs mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-bugs

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages imagemagick depends on:
ii  libbz2-1.0            1.0.3-2            high-quality block-sorting file co
ii  libc6                 2.3.5-12           GNU C Library: Shared libraries an
ii  libfreetype6          2.1.10-1           FreeType 2 font engine, shared lib
ii  libice6               6.9.0.dfsg.1-4     Inter-Client Exchange library
ii  libjasper-1.701-1     1.701.0-2          The JasPer JPEG-2000 runtime libra
ii  libjpeg62             6b-11              The Independent JPEG Group's JPEG 
ii  liblcms1              1.13-1             Color management library
ii  libmagick9            6:6.2.4.5-0.6.kmr1 Image manipulation library
ii  libpng12-0            1.2.8rel-5         PNG library - runtime
ii  libsm6                6.9.0.dfsg.1-4     X Window System Session Management
ii  libtiff4              3.7.4-1            Tag Image File Format (TIFF) libra
ii  libx11-6              6.9.0.dfsg.1-4     X Window System protocol client li
ii  libxext6              6.9.0.dfsg.1-4     X Window System miscellaneous exte
ii  libxml2               2.6.23.dfsg.1-0.1  GNOME XML library
ii  libxt6                6.9.0.dfsg.1-4     X Toolkit Intrinsics
ii  zlib1g                1:1.2.3-9          compression library - runtime

imagemagick recommends no packages.

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to