Mercurial > sdl-ios-xcode
comparison src/video/Xext/Xxf86vm/XF86VMode.c @ 4151:cab9823cb55e SDL-1.2
Prevent crash from unaligned memory access on sparc64, etc.
Fixes Bugzilla #602. I suspect this will crash elsewhere if the system
actually had modelines to report, though.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Mon, 08 Sep 2008 07:33:05 +0000 |
parents | 904defc0792e |
children | e66db1af0714 |
comparison
equal
deleted
inserted
replaced
4150:1019eb074a56 | 4151:cab9823cb55e |
---|---|
210 Gamma->green = ((float)rep.green) / 10000.; | 210 Gamma->green = ((float)rep.green) / 10000.; |
211 Gamma->blue = ((float)rep.blue) / 10000.; | 211 Gamma->blue = ((float)rep.blue) / 10000.; |
212 UnlockDisplay(dpy); | 212 UnlockDisplay(dpy); |
213 SyncHandle(); | 213 SyncHandle(); |
214 return True; | 214 return True; |
215 } | |
216 | |
217 /* this is to prevent an unaligned memory write on CPUs that need that. */ | |
218 static void zap_ptr(char *ptr, size_t size) | |
219 { | |
220 memset(ptr, '\0', size); | |
215 } | 221 } |
216 | 222 |
217 Bool | 223 Bool |
218 SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline) | 224 SDL_NAME(XF86VidModeGetModeLine)(dpy, screen, dotclock, modeline) |
219 Display* dpy; | 225 Display* dpy; |
282 Xfree(modeline->private); | 288 Xfree(modeline->private); |
283 return False; | 289 return False; |
284 } | 290 } |
285 _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); | 291 _XRead(dpy, (char*)modeline->private, modeline->privsize * sizeof(INT32)); |
286 } else { | 292 } else { |
287 modeline->private = NULL; | 293 zap_ptr((char *)&modeline->private, sizeof(modeline->private)) |
288 } | 294 } |
289 UnlockDisplay(dpy); | 295 UnlockDisplay(dpy); |
290 SyncHandle(); | 296 SyncHandle(); |
291 return True; | 297 return True; |
292 } | 298 } |