microsoft / wil

Windows Implementation Library
MIT License
2.58k stars 236 forks source link

Warning: C26451 in win32_helpers (GetModuleFileNameExW) #228

Open smaillet-ms opened 2 years ago

smaillet-ms commented 2 years ago

Running code analysis on a project including WIL headers should compile without issues flagged. Instead we get:

Warning C26451  Arithmetic overflow: Using operator '+' on a 4 byte value and then casting the result to a 8 byte value. Cast the value to the wider type before calling operator '+' to avoid overflow (io.2). [...]\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\include\wil\win32_helpers.h 333 

AND:

Warning C6001   Using uninitialized memory '*pNode'.    [...]\packages\Microsoft.Windows.ImplementationLibrary.1.0.220201.1\include\wil\result.h    388 
jonwis commented 2 years ago

For the life of me, I can't fix the *pNode problem. I've stared at the code for probably two hours and it's completely correct. Roy Williams and the Code Analysis folks agree that there's something about the code that's tripping up the VS checker.

The other one is a real problem.

jonwis commented 2 years ago

The pNode one is tracked as #164 already.