Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- programs/winemenubuilder/winemenubuilder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 16dc32a8859..620086f9776 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -319,7 +319,9 @@ static char *wchars_to_xml_text(const WCHAR *string) { int i, pos; char *text = wchars_to_utf8_chars( string ); - char *ret = xmalloc( 6 * strlen(text) + 1 ); + static char *ret; + + ret = xrealloc( ret, 6 * strlen(text) + 1 );
for (i = pos = 0; text[i]; i++) {
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- 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; }
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- programs/winemenubuilder/winemenubuilder.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 1a11afb7791..900e81dbcf2 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -2018,6 +2018,7 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic struct wine_rb_tree mimeProgidTree = { winemenubuilder_rb_string_compare }; struct list nativeMimeTypes = LIST_INIT(nativeMimeTypes); int i; + WCHAR *icon_name; BOOL hasChanged = FALSE;
if (!build_native_mime_types(&nativeMimeTypes)) @@ -2078,8 +2079,9 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic *comma = 0; index = wcstol(comma + 1, NULL, 10); } - extract_icon(iconW, index, flattened_mime, FALSE); + icon_name = extract_icon(iconW, index, flattened_mime, FALSE); heap_free(flattened_mime); + heap_free(icon_name); }
write_freedesktop_mime_type_entry(packages_dir, extensionW, mimeType, friendlyDocNameW); @@ -2128,7 +2130,11 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic heap_free(desktopPath); }
- if (hasChanged && openWithIcon) extract_icon(executableW, 0, openWithIcon, FALSE); + if (hasChanged && openWithIcon) + { + icon_name = extract_icon(executableW, 0, openWithIcon, FALSE); + heap_free(icon_name); + }
end: heap_free(commandW);
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- programs/winemenubuilder/winemenubuilder.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 900e81dbcf2..958f9b1f1d7 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -2043,7 +2043,7 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic WCHAR *iconW = NULL; WCHAR *contentTypeW = NULL; WCHAR *mimeType = NULL; - const WCHAR *friendlyAppName; + WCHAR *friendlyAppName = NULL; WCHAR *progIdW = NULL; WCHAR *mimeProgId = NULL; struct rb_string_entry *entry; @@ -2098,7 +2098,7 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic openWithIcon = compute_native_identifier(0, executableW, NULL);
friendlyAppName = assoc_query(ASSOCSTR_FRIENDLYAPPNAME, extensionW, L"open"); - if (!friendlyAppName) friendlyAppName = L"A Wine application"; + if (!friendlyAppName) friendlyAppName = xwcsdup(L"A Wine application");
progIdW = reg_get_valW(HKEY_CLASSES_ROOT, extensionW, NULL); if (!progIdW) goto end; /* no progID => not a file type association */ @@ -2144,6 +2144,7 @@ static BOOL generate_associations(const WCHAR *packages_dir, const WCHAR *applic heap_free(iconW); heap_free(contentTypeW); heap_free(mimeType); + heap_free(friendlyAppName); heap_free(progIdW); } heap_free(extensionW);
Alex Henrie alexhenrie24@gmail.com writes:
Signed-off-by: Alex Henrie alexhenrie24@gmail.com
programs/winemenubuilder/winemenubuilder.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Fixing memory leaks in short-lived programs is not worth the trouble.
Hi,
On 29/12/21 13:42, Alexandre Julliard wrote:
Fixing memory leaks in short-lived programs is not worth the trouble.
Out of curiosity, you mean always or just during code freeze?
Giovanni.
Giovanni Mascellani gmascellani@codeweavers.com writes:
Hi,
On 29/12/21 13:42, Alexandre Julliard wrote:
Fixing memory leaks in short-lived programs is not worth the trouble.
Out of curiosity, you mean always or just during code freeze?
Always. It's making the code more complicated for no benefit.