microsoft / winfile

Original Windows File Manager (winfile) with enhancements
MIT License
6.75k stars 698 forks source link

Enable SdlCheck and fix warning for use of uninitialized pointer value #438

Closed malxau-msft closed 2 months ago

malxau-msft commented 3 months ago

As part of generating an official build, one warning was issued for not using SdlCheck (see https://learn.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=msvc-170 .) Enabling this has the effect of enabling use of uninitialized pointer local variables, and most of this change revolves around that. The general pattern seems to be Winfile using two locals, one which is initialized if a second is set, then later consumed if the second is set. The compiler is not smart enough to understand that whenever it is used, the local will be initialized. The changes here have the effect of suppressing the compiler warning, although any use of the local where it hasn't been initialized with the correct value will still be incorrect. About the best thing these changes do is force a deterministic failure rather than consume uninitialized stack and fail in random ways.

This also splits the XP build definition from the regular one, since it seems to have enough XP-specific switches now that doing so is cleaner. SdlCheck is only enabled for the 2022 compiler, so it's not present in the XP build.

schinagl commented 2 months ago

It is about initialization and not about catching exception. This is the most weird argument I have ever heard.

As so many times I agree to disagree with your programming style from the 80s and your attitude of handling changes and running this repo.

This repo has detoriated into @malxau private environment.