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 4154db4007f17bc8
parent 4153 e66db1af0714
child 4155 4d743a3d0bc1
Correct fix for Bugzilla #602.
src/video/Xext/Xxf86vm/XF86VMode.c
src/video/x11/SDL_x11modes.c
     1.1 --- a/src/video/Xext/Xxf86vm/XF86VMode.c	Mon Sep 15 05:08:53 2008 +0000
     1.2 +++ b/src/video/Xext/Xxf86vm/XF86VMode.c	Mon Sep 15 20:47:55 2008 +0000
     1.3 @@ -214,12 +214,6 @@
     1.4      return True;
     1.5  }
     1.6  
     1.7 -/* this is to prevent an unaligned memory write on CPUs that need that. */
     1.8 -static void zap_ptr(char *ptr, size_t size)
     1.9 -{
    1.10 -    memset(ptr, '\0', size);
    1.11 -}
    1.12 -
    1.13  Bool
    1.14  SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline)
    1.15      Display* dpy;
    1.16 @@ -290,7 +284,7 @@
    1.17  	}
    1.18  	_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
    1.19      } else {
    1.20 -	zap_ptr((char *)&modeline->private, sizeof(modeline->private));
    1.21 +	modeline->private = NULL;
    1.22      }
    1.23      UnlockDisplay(dpy);
    1.24      SyncHandle();
     2.1 --- a/src/video/x11/SDL_x11modes.c	Mon Sep 15 05:08:53 2008 +0000
     2.2 +++ b/src/video/x11/SDL_x11modes.c	Mon Sep 15 20:47:55 2008 +0000
     2.3 @@ -52,8 +52,25 @@
     2.4  #if SDL_VIDEO_DRIVER_X11_VIDMODE
     2.5  Bool SDL_NAME(XF86VidModeGetModeInfo)(Display *dpy, int scr, SDL_NAME(XF86VidModeModeInfo) *info)
     2.6  {
     2.7 -    SDL_NAME(XF86VidModeModeLine) *l = (SDL_NAME(XF86VidModeModeLine)*)((char*)info + sizeof info->dotclock);
     2.8 -    return SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, (int*)&info->dotclock, l);
     2.9 +    Bool retval;
    2.10 +    int dotclock;
    2.11 +    SDL_NAME(XF86VidModeModeLine) l;
    2.12 +    SDL_memset(&l, 0, sizeof(l));
    2.13 +    retval = SDL_NAME(XF86VidModeGetModeLine)(dpy, scr, &dotclock, &l);
    2.14 +    info->dotclock = dotclock;
    2.15 +    info->hdisplay = l.hdisplay;
    2.16 +    info->hsyncstart = l.hsyncstart;
    2.17 +    info->hsyncend = l.hsyncend;
    2.18 +    info->htotal = l.htotal;
    2.19 +    info->hskew = l.hskew;
    2.20 +    info->vdisplay = l.vdisplay;
    2.21 +    info->vsyncstart = l.vsyncstart;
    2.22 +    info->vsyncend = l.vsyncend;
    2.23 +    info->vtotal = l.vtotal;
    2.24 +    info->flags = l.flags;
    2.25 +    info->privsize = l.privsize;
    2.26 +    info->private = l.private;
    2.27 +    return retval;
    2.28  }
    2.29  #endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */
    2.30