microsoft / Detours

Detours is a software package for monitoring and instrumenting API calls on Windows. It is distributed in source code form.
MIT License
5.27k stars 1.02k forks source link

Possible errors #74

Open andrew-boyarshin opened 5 years ago

andrew-boyarshin commented 5 years ago

https://github.com/microsoft/Detours/blob/edc8b07ae7e7325d9b9d551b46122a82665161b8/src/detours.cpp#L1761-L1764

V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'o->pTrampoline' class object. detours.cpp 1763

Would someone knowledgeable with the code check the presence of the error in this code block?

There is a large number of PVS-Studio messages, but this one is on a (relatively) hot execution path.

List of all other High-priority messages:

V595 The 'o->pTrampoline' pointer was utilized before it was verified against nullptr. Check lines: 1802, 1805. detours.cpp 1802
V763 Parameter 'pEntry' is always rewritten in function body before being used. disasm.cpp 448
V763 Parameter 'pEntry' is always rewritten in function body before being used. disasm.cpp 592
V730 Not all members of a class are initialized inside the constructor. Consider inspecting: m_nSegmentOverride, m_lScratchExtra, m_pbScratchTarget, m_rbScratchDst. disasm.cpp 328
V595 The 'pcbData' pointer was utilized before it was verified against nullptr. Check lines: 549, 554. image.cpp 549
V568 It's odd that 'sizeof()' operator evaluates the size of a pointer to a class, but not the size of the 'piidDst' class object. image.cpp 1836
V512 A call of the 'memset' function will lead to underflow of the buffer 'piidDst'. image.cpp 1836
V512 A call of the 'memset' function will lead to underflow of the buffer 'piidDst'. image.cpp 1878
AnshuTrivedi commented 4 years ago

@bgianfo what changes have to make? Please can you help me in figuring out this?