present: prevent memory leaks in present_create_notifies()

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 <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith 2026-03-30 12:06:04 -07:00
parent 16ca2c7a11
commit 201563a544

View file

@ -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;