Correct fix for Bugzilla #602. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Mon, 15 Sep 2008 20:47:55 +0000
branchSDL-1.2
changeset 4154 db4007f17bc8
parent 4153 e66db1af0714
child 4155 4d743a3d0bc1
Correct fix for Bugzilla #602.
src/video/Xext/Xxf86vm/XF86VMode.c
src/video/x11/SDL_x11modes.c
--- a/src/video/Xext/Xxf86vm/XF86VMode.c	Mon Sep 15 05:08:53 2008 +0000
+++ b/src/video/Xext/Xxf86vm/XF86VMode.c	Mon Sep 15 20:47:55 2008 +0000
@@ -214,12 +214,6 @@
     return True;
 }
 
-/* this is to prevent an unaligned memory write on CPUs that need that. */
-static void zap_ptr(char *ptr, size_t size)
-{
-    memset(ptr, '\0', size);
-}
-
 Bool
 SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline)
     Display* dpy;
@@ -290,7 +284,7 @@
 	}
 	_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
     } else {
-	zap_ptr((char *)&modeline->private, sizeof(modeline->private));
+	modeline->private = NULL;
     }
     UnlockDisplay(dpy);
     SyncHandle();
--- a/src/video/x11/SDL_x11modes.c	Mon Sep 15 05:08:53 2008 +0000
+++ b/src/video/x11/SDL_x11modes.c	Mon Sep 15 20:47:55 2008 +0000
@@ -52,8 +52,25 @@
 #if SDL_VIDEO_DRIVER_X11_VIDMODE
 Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info)
 {
-    SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock);
-    return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&info->dotclock, l);
+    Bool retval;
+    int dotclock;
+    SDL_NAME(XF86VidModeModeLine) l;
+    SDL_memset(&l, 0, sizeof(l));
+    retval = SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, &dotclock, &l);
+    info->dotclock = dotclock;
+    info->hdisplay = l.hdisplay;
+    info->hsyncstart = l.hsyncstart;
+    info->hsyncend = l.hsyncend;
+    info->htotal = l.htotal;
+    info->hskew = l.hskew;
+    info->vdisplay = l.vdisplay;
+    info->vsyncstart = l.vsyncstart;
+    info->vsyncend = l.vsyncend;
+    info->vtotal = l.vtotal;
+    info->flags = l.flags;
+    info->privsize = l.privsize;
+    info->private = l.private;
+    return retval;
 }
 #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */