guard slices<3 in par_shapes_create_disk, fixed compiler warning -Walloc-size-larger-than

This commit is contained in:
ievanpoikka 2026-06-21 22:11:50 +05:30
parent db0870f31f
commit 73810d54d9

View File

@ -715,6 +715,12 @@ void par_shapes_merge(par_shapes_mesh* dst, par_shapes_mesh const* src)
par_shapes_mesh* par_shapes_create_disk(float radius, int slices, par_shapes_mesh* par_shapes_create_disk(float radius, int slices,
float const* center, float const* normal) float const* center, float const* normal)
{ {
// Guard against degenerate and invalid tessellation counts
// fixes compiler warning -Walloc-size-larger-than
// and a heap-buffer-overflow
if (slices < 3) {
return 0;
}
par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1); par_shapes_mesh* mesh = PAR_CALLOC(par_shapes_mesh, 1);
mesh->npoints = slices + 1; mesh->npoints = slices + 1;
mesh->points = PAR_MALLOC(float, 3 * mesh->npoints); mesh->points = PAR_MALLOC(float, 3 * mesh->npoints);