!8 XcursorXcFileLoad: plug memory leak in error paths

From: @ultra_planet 
Reviewed-by: @t_feng 
Signed-off-by: @t_feng
This commit is contained in:
openeuler-ci-bot 2024-08-02 02:19:54 +00:00 committed by Gitee
commit 69d09d9cff
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 48 additions and 1 deletions

View File

@ -0,0 +1,42 @@
From 5e0f8347cebef2b3a9f5d75ca254aabaa0bca259 Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun, 8 Oct 2023 10:48:25 -0700
Subject: [PATCH] XcursorXcFileLoad: plug memory leak in error paths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Found by gcc analyzer:
file.c: In function XcursorXcFileLoad:
file.c:782:8: warning: leak of fileHeader [CWE-401] [-Wanalyzer-malloc-leak]
782 | if (!images)
| ^
Fixes: 3b84b14 ("Initial revision")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
---
src/file.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/file.c b/src/file.c
index 0e26955..496d447 100644
--- a/src/file.c
+++ b/src/file.c
@@ -780,10 +780,14 @@ XcursorXcFileLoad (XcursorFile *file,
}
images = XcursorImagesCreate (nimage);
if (!images)
+ {
+ _XcursorFileHeaderDestroy (fileHeader);
return 0;
+ }
comments = XcursorCommentsCreate (ncomment);
if (!comments)
{
+ _XcursorFileHeaderDestroy (fileHeader);
XcursorImagesDestroy (images);
return 0;
}
--
2.33.0

View File

@ -3,12 +3,14 @@
Name: libXcursor
Summary: Cursor management library
Version: 1.2.1
Release: 1
Release: 2
License: MIT
URL: https://xorg.freedesktop.org/
Source0: https://xorg.freedesktop.org/archive/individual/lib/%{name}-%{version}.tar.gz
Source1: index.theme
Patch0: backport-XcursorXcFileLoad-plug-memory-leak-in-error-paths.patch
Requires: libX11
BuildRequires: xorg-x11-proto-devel libX11-devel
BuildRequires: autoconf automake libtool xorg-x11-util-macros
@ -68,6 +70,9 @@ install -m644 %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/icons/default/index.theme
%{_mandir}/man3/Xcursor*.3*
%changelog
* Tue Jul 30 2024 lingsheng <lingsheng1@h-partners.com> - 1.2.1-2
- XcursorXcFileLoad: plug memory leak in error paths
* Mon Aug 1 2022 tianlijing <tianlijing@kylinos.cn> - 1.2.1-1
- update to 1.2.1