Page 1 of 1

Distort after scale uses uninitialized values

Posted: 2015-02-22T09:31:04-07:00
by Danack
The code below which does a MagickDistortImage after doing MagickScaleImage gives lots of valgrind "using uninitialized memory" warning.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <wand/MagickWand.h>


int main(int argc,char **argv) {
    MagickWand *magick_wand;
    MagickWandGenesis();
    
    magick_wand = NewMagickWand();

    MagickReadImage(magick_wand, "magick:logo");
    double arguments[] = {
        0.5, 0, 0,
        1, 100, 0
    };
    MagickScaleImage(magick_wand, 400, 300);
    MagickDistortImage(
        magick_wand, 
        AffineProjectionDistortion, 
        6,
        arguments,
        0
    );

    MagickWriteImage(magick_wand, "./edge_output.png");
    MagickWandTerminus();

    return 0;
}

Output
==11779== Conditional jump or move depends on uninitialised value(s)
==11779== at 0x542A1B1: ClampToQuantum (in /usr/lib64/libMagickCore-6.Q16.so.2.0.0)
==11779== by 0x542BB16: ResamplePixelColor (in /usr/lib64/libMagickCore-6.Q16.so.2.0.0)
==11779== by 0x5354724: DistortImage (in /usr/lib64/libMagickCore-6.Q16.so.2.0.0)
==11779== by 0x4F60FA7: MagickDistortImage (in /usr/lib64/libMagickWand-6.Q16.so.2.0.0)
==11779== by 0x400885: main (edgeMemory.c:22)
==11779== ...
==11779== ERROR SUMMARY: 240600 errors from 4 contexts (suppressed: 6 from 6)

Re: Distort after scale uses uninitialized values

Posted: 2015-02-22T10:46:02-07:00
by magick
We can reproduce the problem you posted and have a patch in ImageMagick 6.9.0-8 Beta, available by sometime tomorrow. Thanks.