From: Indrek Altpere Subject: [2/2] winemenubuilder: fix stack overflow caused by invalid icon associations Message-Id: Date: Fri, 29 Aug 2014 16:11:08 +0300 Fixes https://bugs.winehq.org/show_bug.cgi?id=35230 Added file existence check with stat() call before calling open_icon, allowing winemenubuilder -a -r run to completion with Freehand 9 demo installed. Regards, Indrek diff --git a/programs/winemenubuilder/winemenubuilder.c b/programs/winemenubuilder/winemenubuilder.c index 5d16022..0394d9d 100644 --- a/programs/winemenubuilder/winemenubuilder.c +++ b/programs/winemenubuilder/winemenubuilder.c @@ -1018,6 +1018,8 @@ static HRESULT open_file_type_icon(LPCWSTR szFileName, IStream **ppStream) WCHAR *comma; int index = 0; HRESULT hr = HRESULT_FROM_WIN32(ERROR_NOT_FOUND); + char *target_unix = NULL; + struct stat stat_buffer; extension = strrchrW(szFileName, '.'); if (extension == NULL) @@ -1040,9 +1042,19 @@ static HRESULT open_file_type_icon(LPCWSTR szFileName, IStream **ppStream) goto end; } + target_unix = wchars_to_unix_chars(target); + if (!target_unix) + { + hr = E_OUTOFMEMORY; + goto end; + } + if (stat(target_unix, &stat_buffer) != 0) + goto end; + hr = open_icon(target, index, FALSE, ppStream); end: + HeapFree(GetProcessHeap(), 0, target_unix); HeapFree(GetProcessHeap(), 0, target); return hr; }