From faa11d0910a064b3bf76eb3959954ef9b3a1732c Mon Sep 17 00:00:00 2001 From: "Maciej S. Szmigiero" Date: Tue, 8 Aug 2023 16:06:20 +0200 Subject: [PATCH] GTree: Add a G_STATIC_ASSERT for MAX_GTREE_HEIGHT Makes sure we don't accidentally set it too small and overflow a tree path array. Signed-off-by: Maciej S. Szmigiero --- glib/gtree.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/glib/gtree.c b/glib/gtree.c index 1cdd8b9a8..bfae6399d 100644 --- a/glib/gtree.c +++ b/glib/gtree.c @@ -69,6 +69,8 @@ **/ #define MAX_GTREE_HEIGHT 40 +/* G_MAXUINT nodes will be covered by tree height of log2(G_MAXUINT) + 2. */ +G_STATIC_ASSERT ((G_GUINT64_CONSTANT (1) << (MAX_GTREE_HEIGHT - 2)) >= G_MAXUINT); /** * GTree: