[cairo] Uninitialized Values
cecashon at aol.com
cecashon at aol.com
Sun Jun 3 02:30:01 UTC 2018
With valgrind I get a lot of uninitialised values with the following program. Everything draws fine. If the radial pattern code gets commented out then these errors don't occur. A little stuck on this one.
Eric
==3380== Use of uninitialised value of size 4
==3380== at 0x473B1A5: crc32 (in /lib/i386-linux-gnu/libz.so.1.2.8)
==3380== by 0x456E374: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x4576E3F: png_write_chunk_data (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x4576FE5: png_write_chunk (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x457777D: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x45794A4: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x4579B3F: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x4579E60: ??? (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x457DD3F: png_write_row (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x457DF7E: png_write_image (in /lib/i386-linux-gnu/libpng12.so.0.54.0)
==3380== by 0x4110033: ??? (in /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6)
==3380== by 0x4110A6A: cairo_surface_write_to_png (in /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6)
==3380== Uninitialised value was created by a stack allocation
==3380== at 0x440AB5E: ??? (in /usr/lib/i386-linux-gnu/libpixman-1.so.0.33.6)
/*
gcc -Wall -Wextra -g -O0 cairo_test1.c -o cairo_test1 `pkg-config --cflags --libs cairo` -lm
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./cairo_test1
Tested on 32bit Ubuntu16.04
*/
#include<cairo.h>
#include<stdio.h>
#include<math.h>
int main()
{
int i=0;
double width=400.0;
double height=400.0;
double data[12][2];
cairo_surface_t *surface=cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr=cairo_create(surface);
for(i=0;i<12;i++)
{
data[i][0]=(width/4)*cos(30.0*(double)(i)*M_PI/180.0);
data[i][1]=(height/4)*sin(30.0*(double)(i)*M_PI/180.0);
}
cairo_set_source_rgba(cr, 0.0, 1.0, 0.0, 1.0);
cairo_paint(cr);
//cairo_set_source_rgba(cr, 0.0, 0.0, 1.0, 1.0);
cairo_translate(cr, width/2.0, height/2.0);
cairo_pattern_t *radial1=cairo_pattern_create_radial(0.0, 0.0, 0.0, 0.0, 0.0, width/4.0);
cairo_pattern_add_color_stop_rgba(radial1, 0.0, 1.0, 0.0, 0.0, 1.0);
cairo_pattern_add_color_stop_rgba(radial1, 1.0, 0.0, 0.0, 1.0, 1.0);
cairo_set_source(cr, radial1);
cairo_move_to(cr, data[0][0], data[0][1]);
for(i=1;i<12;i++)
{
cairo_line_to(cr, data[i][0], data[i][1]);
cairo_stroke_preserve(cr);
}
cairo_close_path(cr);
cairo_fill(cr);
cairo_surface_write_to_png(surface, "drawing1.png");
printf("Status %i\n", cairo_status(cr));
cairo_pattern_destroy(radial1);
cairo_destroy(cr);
cairo_surface_destroy(surface);
cairo_debug_reset_static_data();
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20180602/014db2e6/attachment.html>
More information about the cairo
mailing list