MagickToMime bug

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

MagickToMime bug

Post by rmabry »

The PerlMagick MagickToMime method crashes, at least in the 6.3.2 Beta I grabbed yesterday.

I freed my version of the offending free() call at line 5200 in Magick.xs and mine/mime now seems well.

Code: Select all

# free(mime);
Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Can you generate a stack trace for us? We tried to reproduce the problem but MagickToMime() works for us.
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: Can you generate a stack trace for us? We tried to reproduce the problem but MagickToMime() works for us.


I should have mentioned that this is on Windows, compiled with VC++7 from ImageMagick-6.3.2-1-windows.zip (Beta); perl, v5.8.8 built for MSWin32-x86-multi-thread.

I executed the following script.

Code: Select all

#!/usr/bin/perl -- 
use Image::Magick;
$image = new Image::Magick;
# $image->Read("logo:");
$m = $image->MagickToMime('tif');
The result was this:

Free to wrong pool 222770 not fdfdfdfd at mimetest.plx line 5.


Here's what the debugger spewed:

Unhandled exception at 0x28085bae in perl.exe: 0xC0000005: Access violation writing location 0x00000000.

perl58.dll!28085bae()
perl58.dll!2808682e()
> Magick.dll!XS_Image__Magick_MagickToMime(interpreter * my_perl=0x00224394, cv * cv=0x00224fa8) Line 5173 C
perl58.dll!28040019()
perl58.dll!2805d49d()
perl58.dll!28023fdf()
perl58.dll!28023e96()
perl58.dll!28023d3f()
perl58.dll!28088a12()
perl58.dll!28088a21()
ntdll.dll!7c9131dc()
ntdll.dll!7c913281()
ntdll.dll!7c913288()
ntdll.dll!7c9106eb()
msvcrt.dll!77c2c3c9()
msvcrt.dll!77c2c3ce()
ntdll.dll!7c910992()
msvcrt.dll!77c2c3ce()
msvcrt.dll!77c2c3e7()
msvcrt.dll!77c2c42e()
msvcrt.dll!77c3ac5f()
perl.exe!00401012()
perl.exe!004010f9()
kernel32.dll!7c816fd7()


The debugger displayed the following hunk of code, the cursor at the marked line:

Code: Select all

#line 5194 "Magick.xs"
  {
    char
      *mime;

    mime=MagickToMime(name);
    RETVAL=newSVpv(mime,0);
  free(mime);
  }
#line 5173 "Magick.c"
	ST(0) = RETVAL;    # <------------------
	sv_2mortal(ST(0));
    }
    XSRETURN(1);
}
I hope this is helpful.

Rick
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Post by magick »

Change
  • free(mime);
to
  • mime=(char *) RelinquishMagickMemory(mime);
User avatar
rmabry
Posts: 148
Joined: 2004-04-13T11:25:27-07:00

Post by rmabry »

magick wrote: Change
  • free(mime);
to
  • mime=(char *) RelinquishMagickMemory(mime);


That does it - thanks.

Rick
Post Reply