MagickCore/blob.c/ReadBlob hangs when reading from Blob created in memory

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
tc33
Posts: 40
Joined: 2012-10-21T22:10:21-07:00
Authentication code: 67789

MagickCore/blob.c/ReadBlob hangs when reading from Blob created in memory

Post by tc33 »

IM: 6.9.3-8
Platform: Win10, MSVC 14, x64
File: magick\blob.c, line 2851

Using Magick++ and MagickCore, the following code produces what seems to be an infinite hang on line 2851 of blob.c:

Code: Select all

auto b = Magick::Blob( [image data in uchar*], [size of data] );
auto img = Magick::Image( b  );
MagickCore::ExceptionInfo *exceptionInfo;
exceptionInfo = MagickCore::AcquireExceptionInfo();
ReadImages( img.constImageInfo(), exceptionInfo );  // hangs here!
(void)MagickCore::DestroyExceptionInfo( exceptionInfo );
The offending line of code seems to attempt to be reading from a file that doesn't exist, from blob.c:

Code: Select all

  switch (image->blob->type)
  {
    case UndefinedStream:
      break;
    case StandardStream:
    case FileStream:
    case PipeStream:
    {
      switch (length)
      {
        default:
        {
          count=(ssize_t) fread(q,1,length,image->blob->file_info.file);  // hangs here
However, the following code works fine, likely due to there being a valid file handle:

Code: Select all

auto img = Magick::Image( "path/to/image.ext" );
MagickCore::ExceptionInfo *exceptionInfo;
exceptionInfo = MagickCore::AcquireExceptionInfo();
ReadImages( img.constImageInfo(), exceptionInfo );  // works fine
(void)MagickCore::DestroyExceptionInfo( exceptionInfo );
I doubt this is a common use case but it did uncover a bug in MagickCore that could probably use some attention one day. Thank you

Edit: Sorry I just noticed there is a 'Bug' forum, this should have went there.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: MagickCore/blob.c/ReadBlob hangs when reading from Blob created in memory

Post by snibgo »

[I'll move this to the bugs forum.]
snibgo's IM pages: im.snibgo.com
Post Reply