[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#512264: Illegal SDL struct access causes segfault



Package: dgen
Version: 1.23-10
Severity: normal
Tags: patch

*** Please type your report below this line ***
DGen, in its current form, attempts to access the "screen" SDL_Surface
struct when it pauses. In normal mode, this is desirable. However, these
accesses were not always prevented from happening in OpenGL mode, segfaulting
the program. I've included a patch that adds these checks below.

sdl.cpp.diff:
--- sdl-orig/sdl.cpp	2009-01-17 20:06:00.000000000 -0600
+++ sdl/sdl.cpp	2009-01-17 22:12:50.000000000 -0600
@@ -457,6 +457,9 @@
   
   // If you need to do any sort of locking before writing to the buffer, do so
   // here.
+#ifdef SDL_OPENGL_SUPPORT
+	if(!opengl) /*Don't do this in OpenGL mode; it crashes the emu*/
+#endif
   if(SDL_MUSTLOCK(screen))
     SDL_LockSurface(screen);
   
@@ -597,6 +600,9 @@
       q += mdscr.pitch;
     }
   // Unlock when you're done!
+#ifdef SDL_OPENGL_SUPPORT
+	if(!opengl)
+#endif
   if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen);
   // Update the screen
 #ifdef SDL_OPENGL_SUPPORT
@@ -917,6 +923,9 @@
 #ifdef HAVE_SDL_WM_TOGGLEFULLSCREEN
 	    int fullscreen = 0;
 	    // Switch out of fullscreen mode (assuming this is supported)
+#ifdef SDL_OPENGL_SUPPORT
+		if(!opengl)
+#endif
 	    if(screen->flags & SDL_FULLSCREEN) {
 	      fullscreen = 1;
 	      SDL_WM_ToggleFullScreen(screen);
@@ -1085,7 +1094,6 @@
 inline void pd_clear_message()
 {
   int i, j;
-  long *p = (long*)((char*)screen->pixels + (screen->pitch * ys));
 #ifdef SDL_OPENGL_SUPPORT
   if(opengl)
     {
@@ -1096,6 +1104,9 @@
   else
     {
 #endif
+	/*This line causes problems in OpenGL mode, so we put it here*/
+	/*This actually makes more sense, since it's not used up there*/
+	long *p = (long*)((char*)screen->pixels + (screen->pitch * ys));
       for(i = 0; i < 16; ++i, p += (screen->pitch >> 2))
         for(j = 0; j < 80 * screen->format->BytesPerPixel; ++j)
           p[j] = 0;


-- System Information:
Debian Release: 5.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (101, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.28-3 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages dgen depends on:
ii  libc6                        2.7-18      GNU C Library: Shared libraries
ii  libgcc1                      1:4.3.2-1.1 GCC support library
ii  libgl1-mesa-glx [libgl1]     7.0.3-7     A free implementation of the OpenG
ii  libsdl1.2debian              1.2.13-2    Simple DirectMedia Layer
ii  libstdc++6                   4.3.2-1.1   The GNU Standard C++ Library v3

dgen recommends no packages.

dgen suggests no packages.

-- no debconf information



      



Reply to: