From 73810d54d93b7f64d79059e288e7b10a4ff588a7 Mon Sep 17 00:00:00 2001 From: ievanpoikka Date: Sun, 21 Jun 2026 22:11:50 +0530 Subject: [PATCH] guard slices<3 in par_shapes_create_disk, fixed compiler warning -Walloc-size-larger-than --- src/external/par_shapes.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/external/par_shapes.h b/src/external/par_shapes.h index d5309137b..adde5865f 100644 --- a/src/external/par_shapes.h +++ b/src/external/par_shapes.h @@ -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, 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); mesh->npoints = slices + 1; mesh->points = PAR_MALLOC(float, 3 * mesh->npoints);