Bug 1409258 Adjust the definition of NPEvent and resolve uint -> int narrowing in dom/plugins r=jimm
authorTom Ritter <tom@mozilla.com>
Tue, 17 Oct 2017 12:04:51 -0500
changeset 386808 73c16ac042912a583fb927b9682b2771a95f6bbf
parent 386807 3e050546fe966ee1afce6e24e3dadfaa146133a3
child 386809 398dfb7487ae01de5db3b8a3207472edaedf56e9
push id96311
push userarchaeopteryx@coole-files.de
push dateWed, 18 Oct 2017 09:52:02 +0000
treeherdermozilla-inbound@a8a1e8cc1980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1409258
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1409258 Adjust the definition of NPEvent and resolve uint -> int narrowing in dom/plugins r=jimm lParam is a long int (signed) while wparam is unsigned. Correct lParam to be an intptr MozReview-Commit-ID: BeWJUM798O5
dom/plugins/base/npapi.h
dom/plugins/ipc/PluginInstanceChild.cpp
--- a/dom/plugins/base/npapi.h
+++ b/dom/plugins/base/npapi.h
@@ -559,17 +559,17 @@ typedef EventRecord NPEvent;
 #endif
 #elif defined(XP_SYMBIAN)
 typedef QEvent NPEvent;
 #elif defined(XP_WIN)
 typedef struct _NPEvent
 {
   uint16_t event;
   uintptr_t wParam;
-  uintptr_t lParam;
+  intptr_t lParam;
 } NPEvent;
 #elif defined(XP_UNIX) && defined(MOZ_X11)
 typedef XEvent NPEvent;
 #else
 typedef void*  NPEvent;
 #endif
 
 #if defined(XP_MACOSX)
old mode 100644
new mode 100755
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -3304,20 +3304,24 @@ PluginInstanceChild::UpdateWindowAttribu
 #endif // XP_MACOSX
 
 #ifdef XP_WIN
     // Windowless plugins on Windows need a WM_WINDOWPOSCHANGED event to update
     // their location... or at least Flash does: Silverlight uses the
     // window.x/y passed to NPP_SetWindow
 
     if (mPluginIface->event) {
+        // width and height are stored as units, but narrow to ints here
+        MOZ_RELEASE_ASSERT(mWindow.width <= INT_MAX);
+        MOZ_RELEASE_ASSERT(mWindow.height <= INT_MAX);
+
         WINDOWPOS winpos = {
             0, 0,
             mWindow.x, mWindow.y,
-            mWindow.width, mWindow.height,
+            (int32_t)mWindow.width, (int32_t)mWindow.height,
             0
         };
         NPEvent pluginEvent = {
             WM_WINDOWPOSCHANGED, 0,
             (LPARAM) &winpos
         };
         mPluginIface->event(&mData, &pluginEvent);
     }
@@ -3374,17 +3378,17 @@ PluginInstanceChild::PaintRectToPlatform
         mWindow.x + aRect.x,
         mWindow.y + aRect.y,
         mWindow.x + aRect.XMost(),
         mWindow.y + aRect.YMost()
     };
     NPEvent paintEvent = {
         WM_PAINT,
         uintptr_t(mWindow.window),
-        uintptr_t(&rect)
+        intptr_t(&rect)
     };
 
     ::SetViewportOrgEx((HDC) mWindow.window, -mWindow.x, -mWindow.y, nullptr);
     ::SelectClipRgn((HDC) mWindow.window, nullptr);
     ::IntersectClipRect((HDC) mWindow.window, rect.left, rect.top, rect.right, rect.bottom);
     mPluginIface->event(&mData, reinterpret_cast<void*>(&paintEvent));
 #else
     MOZ_CRASH("Surface type not implemented.");