Page 1 of 1

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

Posted: 2016-04-27T09:13:40-07:00
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.

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

Posted: 2016-04-27T14:57:32-07:00
by snibgo
[I'll move this to the bugs forum.]