Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[win32] LvData: Initialize HDITEM::mask.
This somehow managed to mostly work on Windows 7, and even for a while on Windows 10. Starting with commit 59c3d23 in v2.4, opening the ROM Properties tab would usually crash for EXE/DLL files due to the Import and/or Export tabs, which have RFT_LISTDATA. I wasn't able to reproduce this in any Debug builds, but it showed up on Windows 10 in Release builds with MSVC 17.6.5. The effects were seemingly random, depending on what code I moved around; sometimes it'd crash, other times it'd cause the column titles to show up as garbage. Using a TCHAR[] buffer instead of a tstring seemed to have fixed the problem, until the garbage titles showed up. (This merely moved the problem around due to the stack layout.) Making the TCHAR[] buffer static made the problem worse, since it *removed* stuff from the stack. In the end, the problem was really very obvious once I saw it. Disabling LvData's sorting functions caused everything to "just work". When I looked at the functions, I saw Header_GetItem() called immediately after the HDITEM variable was declared. HDITEM, like LVCOLUMN, has a mask field which *must* be filled in for both Set and Get. Otherwise, it might try reading text into whatever's in HDITEM::pszText, which is likely the cause of the crashes. The garbage text could be explained by somehow getting through Header_GetItem(), only to have garbage text set by Header_SetItem(). Fixes #432: [Bug Report] EXE/DLL files causes a crash Reported by @xxmichibxx. Affects: v2.4 - v2.4.1 (Windows only), but it's entirely possible that older versions could have random glitches as well.
- Loading branch information