[MPlayer-cvslog] r38428 - in trunk/libvo: gl_common.c x11_common.c
reimar
subversion at mplayerhq.hu
Tue Jun 6 17:06:11 EEST 2023
Author: reimar
Date: Tue Jun 6 17:06:10 2023
New Revision: 38428
Log:
libvo: improve error handling for had -wid.
Avoids crashes if -wid specifies a window ID
that is not or no longer valid.
Improves behaviour reported in trac issue #2411.
Modified:
trunk/libvo/gl_common.c
trunk/libvo/x11_common.c
Modified: trunk/libvo/gl_common.c
==============================================================================
--- trunk/libvo/gl_common.c Tue Jun 6 16:56:37 2023 (r38427)
+++ trunk/libvo/gl_common.c Tue Jun 6 17:06:10 2023 (r38428)
@@ -2238,7 +2238,8 @@ static XVisualInfo *getWindowVisualInfo(
XWindowAttributes xw_attr;
XVisualInfo vinfo_template;
int tmp;
- XGetWindowAttributes(mDisplay, win, &xw_attr);
+ if (!XGetWindowAttributes(mDisplay, win, &xw_attr))
+ return DefaultVisual(mDisplay, 0);
vinfo_template.visualid = XVisualIDFromVisual(xw_attr.visual);
return XGetVisualInfo(mDisplay, VisualIDMask, &vinfo_template, &tmp);
}
Modified: trunk/libvo/x11_common.c
==============================================================================
--- trunk/libvo/x11_common.c Tue Jun 6 16:56:37 2023 (r38427)
+++ trunk/libvo/x11_common.c Tue Jun 6 17:06:10 2023 (r38428)
@@ -1397,16 +1397,19 @@ static int vo_x11_get_fs_type(int suppor
* \return returns current color depth of vo_window
*/
int vo_x11_update_geometry(void) {
- unsigned depth, w, h;
+ unsigned depth, w = 0, h = 0;
int dummy_int;
Window dummy_win;
XGetGeometry(mDisplay, vo_window, &dummy_win, &dummy_int, &dummy_int,
&w, &h, &dummy_int, &depth);
- if (w <= INT_MAX && h <= INT_MAX) {
+ if (w > 0 && h > 0 && w <= INT_MAX && h <= INT_MAX) {
vo_dwidth = w;
vo_dheight = h;
vo_x11_update_fs_borders();
}
+ // ensure minimum value of 1, to avoid e.g. division by 0.
+ if (vo_dwidth <= 0) vo_dwidth = 1;
+ if (vo_dheight <= 0) vo_dheight = 1;
XTranslateCoordinates(mDisplay, vo_window, mRootWin, 0, 0, &vo_dx, &vo_dy,
&dummy_win);
More information about the MPlayer-cvslog
mailing list