Page 1 of 1

MagickMorphologyImage function definition not matching arguments

Posted: 2019-09-02T10:07:37-07:00
by coloring
The function for MagickWand's MagickMorphologyImage has two non-const arguments, method and kernel, which are both used in const only ways -> MorhplogyImage takes only const arguments. For clarity reasons, maybe it should be changed to a const signature?

Rationale: I thought that somehow the code would be trying to modify the *kernel I passed into it, only to find that it's actually const and doesn't modify it.

Code: Select all

MagickExport Image *MorphologyImage(const Image *image,
  const MorphologyMethod method,const ssize_t iterations,
  const KernelInfo *kernel,ExceptionInfo *exception)

Code: Select all

WandExport MagickBooleanType MagickMorphologyImage(MagickWand *wand,
  MorphologyMethod method,const ssize_t iterations,KernelInfo *kernel)
{
  Image
    *morphology_image;

  assert(wand != (MagickWand *) NULL);
  assert(wand->signature == MagickWandSignature);
  if (wand->debug != MagickFalse)
    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
  if (kernel == (const KernelInfo *) NULL)
    return(MagickFalse);
  if (wand->images == (Image *) NULL)
    ThrowWandException(WandError,"ContainsNoImages",wand->name);
  morphology_image=MorphologyImage(wand->images,method,iterations,kernel,
    wand->exception);
  if (morphology_image == (Image *) NULL)
    return(MagickFalse);
  ReplaceImageInList(&wand->images,morphology_image);
  return(MagickTrue);
}

Re: MagickMorphologyImage function definition not matching arguments

Posted: 2019-09-02T12:50:22-07:00
by magick
Agree. Will add a patch to the Git repo by tomorrow.

Re: MagickMorphologyImage function definition not matching arguments

Posted: 2019-09-02T22:39:20-07:00
by coloring
Thanks for the always quick reply, and attention to detail :D