From: Vadim Zeitlin Date: Fri, 30 Mar 2007 13:34:41 +0000 (+0000) Subject: don't dereferencep ossibly NULL pointers in DoScreenToClient/ClientToScreen() X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c5c01214025f3682c2eaf79d5476c8c82f9c920b don't dereferencep ossibly NULL pointers in DoScreenToClient/ClientToScreen() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45142 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/motif/window.cpp b/src/motif/window.cpp index 1f7b234e60..66428802a9 100644 --- a/src/motif/window.cpp +++ b/src/motif/window.cpp @@ -1212,9 +1212,11 @@ void wxWindow::DoScreenToClient(int *x, int *y) const Window thisWindow = XtWindow(widget); Window childWindow; - int xx = *x; - int yy = *y; - XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); + int xx = x ? *x : 0; + int yy = y ? *y : 0; + XTranslateCoordinates(display, rootWindow, thisWindow, + xx, yy, x ? x : &xx, y ? y : &yy, + &childWindow); } void wxWindow::DoClientToScreen(int *x, int *y) const @@ -1225,9 +1227,11 @@ void wxWindow::DoClientToScreen(int *x, int *y) const Window thisWindow = XtWindow(widget); Window childWindow; - int xx = *x; - int yy = *y; - XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow); + int xx = x ? *x : 0; + int yy = y ? *y : 0; + XTranslateCoordinates(display, thisWindow, rootWindow, + xx, yy, x ? x : &xx, y ? y : &yy, + &childWindow); } diff --git a/src/x11/window.cpp b/src/x11/window.cpp index f10becfa7f..13b0e790db 100644 --- a/src/x11/window.cpp +++ b/src/x11/window.cpp @@ -805,9 +805,11 @@ void wxWindowX11::DoScreenToClient(int *x, int *y) const Window thisWindow = (Window) m_clientWindow; Window childWindow; - int xx = *x; - int yy = *y; - XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); + int xx = x ? *x : 0; + int yy = y ? *y : 0; + XTranslateCoordinates(display, rootWindow, thisWindow, + xx, yy, x ? x : &xx, y ? y : &yy, + &childWindow); } void wxWindowX11::DoClientToScreen(int *x, int *y) const @@ -816,10 +818,11 @@ void wxWindowX11::DoClientToScreen(int *x, int *y) const Window rootWindow = RootWindowOfScreen(DefaultScreenOfDisplay(display)); Window thisWindow = (Window) m_clientWindow; - Window childWindow; - int xx = *x; - int yy = *y; - XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow); + int xx = x ? *x : 0; + int yy = y ? *y : 0; + XTranslateCoordinates(display, thisWindow, rootWindow, + xx, yy, x ? x : &xx, y ? y : &yy, + &childWindow); }