Skip to content

Commit

Permalink
Prevent crash from unaligned memory access on sparc64, etc.
Browse files Browse the repository at this point in the history
Fixes Bugzilla #602. I suspect this will crash elsewhere if the system
 actually had modelines to report, though.
  • Loading branch information
icculus committed Sep 8, 2008
1 parent cd840be commit c43c124
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/video/Xext/Xxf86vm/XF86VMode.c
Expand Up @@ -214,6 +214,12 @@ SDL_NAME(XF86VidModeGetGamma)(Display *dpy, int screen, SDL_NAME(XF86VidModeGamm
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;
Expand Down Expand Up @@ -284,7 +290,7 @@ SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline)
}
_XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32));
} else {
modeline->private = NULL;
zap_ptr((char *)&modeline->private, sizeof(modeline->private))
}
UnlockDisplay(dpy);
SyncHandle();
Expand Down

0 comments on commit c43c124

Please sign in to comment.