-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path222715.mypatch
61 lines (52 loc) · 2.16 KB
/
222715.mypatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From: Alex Henrie <[email protected]>
Subject: [PATCH 2/4] winemenubuilder: Fix memory leak in write_desktop_entry (Coverity)
Message-Id: <[email protected]>
Date: Tue, 28 Dec 2021 21:14:09 -0700
In-Reply-To: <[email protected]>
References: <[email protected]>
Signed-off-by: Alex Henrie <[email protected]>
---
programs/winemenubuilder/winemenubuilder.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c
index 620086f9776..1a11afb7791 100644
--- a/programs/winemenubuilder/winemenubuilder.c
+++ b/programs/winemenubuilder/winemenubuilder.c
@@ -1251,6 +1251,7 @@ static BOOL write_desktop_entry(const WCHAR *link, const WCHAR *location, const
int needs_chmod = FALSE;
const WCHAR *name;
const WCHAR *prefix = _wgetenv( L"WINECONFIGDIR" );
+ WCHAR *default_location = NULL;
WINE_TRACE("(%s,%s,%s,%s,%s,%s,%s,%s,%s)\n", wine_dbgstr_w(link), wine_dbgstr_w(location),
wine_dbgstr_w(linkname), wine_dbgstr_w(path), wine_dbgstr_w(args),
@@ -1260,13 +1261,17 @@ static BOOL write_desktop_entry(const WCHAR *link, const WCHAR *location, const
name = PathFindFileNameW( linkname );
if (!location)
{
- location = heap_wprintf(L"%s\\%s.desktop", xdg_desktop_dir, name);
+ default_location = heap_wprintf(L"%s\\%s.desktop", xdg_desktop_dir, name);
+ location = default_location;
needs_chmod = TRUE;
}
file = _wfopen( location, L"wb" );
if (file == NULL)
+ {
+ heap_free(default_location);
return FALSE;
+ }
fprintf(file, "[Desktop Entry]\n");
fprintf(file, "Name=%s\n", wchars_to_utf8_chars(name));
@@ -1303,9 +1308,13 @@ static BOOL write_desktop_entry(const WCHAR *link, const WCHAR *location, const
{
DWORD ret = register_menus_entry(location, link);
if (ret != ERROR_SUCCESS)
+ {
+ heap_free(default_location);
return FALSE;
+ }
}
+ heap_free(default_location);
return TRUE;
}
--
2.34.1