bpo-34770: Fix a possible null pointer dereference in pyshellext.cpp … · python/cpython@936d740 (original) (raw)

Original file line number Diff line number Diff line change
@@ -172,6 +172,11 @@ class PyShellExt : public RuntimeClass<
172 172 return E_FAIL;
173 173 }
174 174 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 + }
175 180 StringCchCopy(dd->szMessage, sizeof(dd->szMessage) / sizeof(dd->szMessage[0]), DRAG_MESSAGE);
176 181 StringCchCopy(dd->szInsert, sizeof(dd->szInsert) / sizeof(dd->szInsert[0]), PathFindFileNameW(target));
177 182 dd->type = DROPIMAGE_MOVE;