Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Use of uninitialized memory and memory leaks #55

Open
turol opened this issue Aug 5, 2022 · 0 comments
Open

Use of uninitialized memory and memory leaks #55

turol opened this issue Aug 5, 2022 · 0 comments

Comments

@turol
Copy link
Contributor

turol commented Aug 5, 2022

Valgrind says:

Conditional jump or move depends on uninitialised value(s)
   at 0x48A74F8: sqrt (w_sqrt_compat.c:31)
   by 0x109F93: par_shapes__normalize3 (par_shapes.h:291)
   by 0x10CC99: par_shapes_scale (par_shapes.h:840)
   by 0x110364: par_shapes_weld (par_shapes.h:1805)
   by 0x10A1C6: par_shapes__compute_welded_normals (par_shapes.h:324)
   by 0x10A9F6: par_shapes_create_parametric (par_shapes.h:492)
   by 0x10A2D6: par_shapes_create_cylinder (par_shapes.h:343)
   by 0x111360: main (test_shapes.c:17)
 Uninitialised value was created by a heap allocation
   at 0x483F7B5: malloc (vg_replace_malloc.c:381)
   by 0x10A189: par_shapes__compute_welded_normals (par_shapes.h:322)
   by 0x10A9F6: par_shapes_create_parametric (par_shapes.h:492)
   by 0x10A2D6: par_shapes_create_cylinder (par_shapes.h:343)
   by 0x111360: main (test_shapes.c:17)

and also memory leaks:

2,772 bytes in 1 blocks are definitely lost in loss record 1 of 2
   at 0x483F7B5: malloc (vg_replace_malloc.c:381)
   by 0x10A189: par_shapes__compute_welded_normals (par_shapes.h:322)
   by 0x10A9F6: par_shapes_create_parametric (par_shapes.h:492)
   by 0x10A524: par_shapes_create_klein_bottle (par_shapes.h:404)
   by 0x111B28: main (test_shapes.c:77)

This is caused by m->normals already being set and unconditionally overwritten here:

m->normals = PAR_MALLOC(float, m->npoints * 3);

I'm not sure what the right fix is here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant