Skip to content

Commit

Permalink
v.generalize: Initialize all of structure contents before using it (#…
Browse files Browse the repository at this point in the history
…4281)

* v.generalize: Initialize all of structure contents before using it

Currently, in `head` which is a `POINT_LIST` structure, we are
only initializing the next pointer to NULL, but data present
in the point substructure is not initialized which implies that
it would be filled with random data. To avoid such scenario,
initialize point coordinates to zero.

This was found using cppcheck tool.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>

* Use correct literal for double type

Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>

---------

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
  • Loading branch information
ymdatta and nilason authored Sep 10, 2024
1 parent a85c7b0 commit 76507cc
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions vector/v.generalize/smoothing.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ int hermite(struct line_pnts *Points, double step, double angle_thresh,
angle_thresh *= M_PI / 180.0;

head.next = NULL;
head.p.x = head.p.y = head.p.z = 0.0;
point = last = &head;

if (!is_loop) {
Expand Down

0 comments on commit 76507cc

Please sign in to comment.