bpo-34770: Fix a possible null pointer dereference in pyshellext.cpp (GH-9497)

The GlobalLock() call in UpdateDropDescription() was not checked for
failure.



https://bugs.python.org/issue34770
This commit is contained in:
Zackery Spytz 2018-09-24 22:25:23 -06:00 committed by Miss Islington (bot)
parent b60b4683f6
commit f6c8007a29
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1 @@
Fix a possible null pointer dereference in pyshellext.cpp.

View File

@ -172,6 +172,11 @@ private:
return E_FAIL;
}
auto dd = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal);
if (!dd) {
OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to lock DROPDESCRIPTION hGlobal");
ReleaseStgMedium(&medium);
return E_FAIL;
}
StringCchCopy(dd->szMessage, sizeof(dd->szMessage) / sizeof(dd->szMessage[0]), DRAG_MESSAGE);
StringCchCopy(dd->szInsert, sizeof(dd->szInsert) / sizeof(dd->szInsert[0]), PathFindFileNameW(target));
dd->type = DROPIMAGE_MOVE;