calref / cboe

Classic Blades of Exile
http://spiderwebforums.ipbhost.com/index.php?/forum/12-blades-of-exile/
Other
173 stars 42 forks source link

Make sure lpstrFile is empty on cancel #305

Closed NQNStudios closed 1 year ago

NQNStudios commented 1 year ago

I built the game on Windows and found that I actually couldn't reproduce #268 -- because it seems that dlg.lpstrFile is actually an empty string in the case of a cancel or an error. At least, when built with Visual Studio 2017, that was the case when I debugged it a few times.

Maybe it's not guaranteed that lpstrFile will be an empty string, and random behavior caused this bug. I've added a commit that sets it to an empty string, which will guarantee that doesn't happen.

This, unlike my previous PR, also avoids leaking memory by following the same control flow as before.

This should close #268.

CelticMinstrel commented 1 year ago

The approach looks fine but the CI says it doesn't compile using the Microsoft toolchain. Perhaps setting the first character to 0 instead would work?