From 201563a5440bb0e85546fd439935a1c19cebe877 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Mon, 30 Mar 2026 12:06:04 -0700 Subject: [PATCH] present: prevent memory leaks in present_create_notifies() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported in #1817: xwayland-24.1.6/redhat-linux-build/../present/present_notify.c:83:17: warning[-Wanalyzer-malloc-leak]: leak of ‘notifies’ xwayland-24.1.6/redhat-linux-build/../present/present_notify.c:83:17: branch_false: following ‘false’ branch (when ‘i >= num_notifies’)... Signed-off-by: Alan Coopersmith --- present/present_notify.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/present/present_notify.c b/present/present_notify.c index 00b3b68bd..fdd15463b 100644 --- a/present/present_notify.c +++ b/present/present_notify.c @@ -76,6 +76,13 @@ present_create_notifies(ClientPtr client, int num_notifies, xPresentNotify *x_no int added = 0; int status; + if (num_notifies <= 0) { + if (num_notifies == 0) + return Success; + else + return BadLength; + } + notifies = calloc (num_notifies, sizeof (present_notify_rec)); if (!notifies) return BadAlloc;