Segmentation fault on ImageToBlob if compression failed

Post any defects you find in the released or beta versions of the ImageMagick software here. The ImageMagick maintainers carefully monitor this list and will work diligently to repair any reported problems. When posting a bug report, please specify both the ImageMagick version and operating system you are using.

Segmentation fault on ImageToBlob if compression failed

Postby ragesteel » 2009-03-19T09:07:19+00:00

Segmentation fault on ImageToBlob if compression failed.

Yes, it is also a bug in JasPer, that cannot compress such image, but it is not reason to Segmentation fault.
If i use WriteImage instead of ImageToBlob, i got just get false as result.

Image for test: http://img.gt2.ru/idx-83.bmp
ImageMagick version: 6.5.0-2
Operation system: openSUSE 11.1

Some problem also appeared on CentOS 5.2 with ImageMagick 6.4.9-4

Code: Select all
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <magick/MagickCore.h>

int main(int argc, char **argv) {
   char *path = argv[0];

   ExceptionInfo *exception_info;
   ImageInfo *image_info, *jp2_image_info;
   Image *image;
   unsigned char *image_blob;
   size_t image_blob_len;
   MagickBooleanType write_image_rc;

   MagickCoreGenesis(path, MagickTrue);

   image_info = CloneImageInfo((ImageInfo *) NULL);
   (void) strcpy(image_info->filename, "idx-83.bmp");

   exception_info = AcquireExceptionInfo();
        image = ReadImage(image_info, exception_info);

   if (UndefinedException != exception_info->severity) {
      CatchException(exception_info);
   }
   if ((Image *) NULL == image) {
      fprintf(stderr, "Unable to read image file!\n");
      exit(1);
   }

   // WriteImage at least does not crush whole application
   jp2_image_info = CloneImageInfo((ImageInfo *) NULL);
   (void) strcpy(jp2_image_info->filename, "idx-83.jp2");
   write_image_rc = WriteImage(jp2_image_info, image);
   fprintf(stdout, "Write image result: %d\n", write_image_rc);
   jp2_image_info = DestroyImageInfo(jp2_image_info);

   // ImageToBlob does crush
        jp2_image_info = CloneImageInfo((ImageInfo *) NULL);
   (void) strcpy(jp2_image_info->magick, "JP2");

   image_blob = ImageToBlob(jp2_image_info, image, &image_blob_len, exception_info);
   fprintf(stdout, "Image blob length is %d\n", image_blob_len);


   jp2_image_info = DestroyImageInfo(jp2_image_info);
         image = DestroyImage(image);
   image_info = DestroyImageInfo(image_info);
       exception_info = DestroyExceptionInfo(exception_info);

   MagickCoreTerminus();
   return 0;
}
ragesteel
 
Posts: 2
Joined: 2009-03-19T08:37:53+00:00

Re: Segmentation fault on ImageToBlob if compression failed

Postby magick » 2009-03-19T09:37:12+00:00

We have a fix for the problem you reported. Look for it in the Subversion trunk by sometime tomorrow.
User avatar
magick
Site Admin
 
Posts: 5671
Joined: 2003-05-31T11:32:55+00:00


Return to Bugs

Who is online

Users browsing this forum: MSN [Bot] and 1 guest