Skip to content

Commit 32ce7ad

Browse files
committed
Fix uninitialized variables in mesh
1 parent d05cb0f commit 32ce7ad

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

mcstas-comps/union/Union_mesh.comp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -929,8 +929,10 @@ if (mask_string &&
929929
// We assume that the input file is using triangular faces, otherwise
930930
// the check for closed mesh using the Euler-Poincare characteristic
931931
// is wrong.
932-
int n_verts, n_faces, n_edges;
933-
Coords* verts;
932+
int n_verts = 0;
933+
int n_faces = 0;
934+
int n_edges = 0;
935+
Coords* verts = coords_set(0,0,0);
934936
int** faces;
935937
int unique_index = 0;
936938

@@ -1016,6 +1018,10 @@ if (mesh_is_not_closed(n_faces,n_verts,n_edges) && !skip_convex_check){
10161018
// Calculate bounding box
10171019
double max_dist = 0;
10181020
double dist = 0;
1021+
if (n_verts <= 0 ){
1022+
printf("\nERROR: Number of vertices read is 0\n");
1023+
exit(1);
1024+
}
10191025
Coords B_sphere_x = verts[0];
10201026
Coords B_sphere_y = B_sphere_x;
10211027

0 commit comments

Comments
 (0)