Page 1 of 1

MagickSetImageFilename is a no-op when passed a null, but returns MagickTrue?

Posted: 2019-08-29T17:21:12-07:00
by coloring
Perhaps I'm reading this code wrong (I'm new to C), but from what I see, if the filename is NULL, it returns MagickTrue, as if it set the filename successfully, but it actually didn't do anything. It looks like a unintentional no-op to me.

Or maybe I'm missing something, and people should simply be smart enough not to pass a NULL in the first place

Code: Select all

WandExport MagickBooleanType MagickSetImageFilename(MagickWand *wand,
  const char *filename)
{
  assert(wand != (MagickWand *) NULL);
  assert(wand->signature == MagickWandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
  if (wand->images == (Image *) NULL)
    ThrowWandException(WandError,"ContainsNoImages",wand->name);
  if (filename != (const char *) NULL)
    (void) CopyMagickString(wand->images->filename,filename,MagickPathExtent);
  return(MagickTrue);
}

Re: MagickSetImageFilename is a no-op when passed a null, but returns MagickTrue?

Posted: 2019-08-30T04:08:27-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.