]> granicus.if.org Git - python/commitdiff
bpo-34770: Fix a possible null pointer dereference in pyshellext.cpp (GH-9497)
authorZackery Spytz <zspytz@gmail.com>
Tue, 25 Sep 2018 04:25:23 +0000 (22:25 -0600)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 25 Sep 2018 04:25:23 +0000 (21:25 -0700)
The GlobalLock() call in UpdateDropDescription() was not checked for
failure.

https://bugs.python.org/issue34770

Misc/NEWS.d/next/Windows/2018-09-22-11-02-35.bpo-34770.4lEUOd.rst [new file with mode: 0644]
PC/pyshellext.cpp

diff --git a/Misc/NEWS.d/next/Windows/2018-09-22-11-02-35.bpo-34770.4lEUOd.rst b/Misc/NEWS.d/next/Windows/2018-09-22-11-02-35.bpo-34770.4lEUOd.rst
new file mode 100644 (file)
index 0000000..5e4ba88
--- /dev/null
@@ -0,0 +1 @@
+Fix a possible null pointer dereference in pyshellext.cpp.
index 04fe61e89618bd78a16353b70654e804f94002a0..019880264bee92946deea391d0a765a29c061f9f 100644 (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;