Skip to content

Commit db23206

Browse files
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 (cherry picked from commit f6c8007) Co-authored-by: Zackery Spytz <[email protected]>
1 parent bbdf872 commit db23206

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a possible null pointer dereference in pyshellext.cpp.

PC/pyshellext.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ class PyShellExt : public RuntimeClass<
172172
return E_FAIL;
173173
}
174174
auto dd = (DROPDESCRIPTION*)GlobalLock(medium.hGlobal);
175+
if (!dd) {
176+
OutputDebugString(L"PyShellExt::UpdateDropDescription - failed to lock DROPDESCRIPTION hGlobal");
177+
ReleaseStgMedium(&medium);
178+
return E_FAIL;
179+
}
175180
StringCchCopy(dd->szMessage, sizeof(dd->szMessage) / sizeof(dd->szMessage[0]), DRAG_MESSAGE);
176181
StringCchCopy(dd->szInsert, sizeof(dd->szInsert) / sizeof(dd->szInsert[0]), PathFindFileNameW(target));
177182
dd->type = DROPIMAGE_MOVE;

0 commit comments

Comments
 (0)