diff -ur original/src/video/windx5/SDL_dx5video.c patched/src/video/windx5/SDL_dx5video.c --- original/src/video/windx5/SDL_dx5video.c Sun Dec 30 20:48:14 2007 +++ patched/src/video/windx5/SDL_dx5video.c Sat Jun 20 21:36:02 2009 @@ -1641,6 +1641,7 @@ struct private_hwdata { LPDIRECTDRAWSURFACE3 dd_surface; LPDIRECTDRAWSURFACE3 dd_writebuf; + void *buffer; }; static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, @@ -1818,6 +1819,7 @@ } } surface->hwdata->dd_writebuf = dd_surface3; + surface->hwdata->buffer = NULL; /* We're ready to go! */ return(0); @@ -2067,6 +2069,9 @@ ((ddsd.dwWidth-surface->w)/2)* surface->format->BytesPerPixel; } + if ( !surface->hwdata->buffer && surface->pixels ) { + surface->hwdata->buffer = surface->pixels; + } surface->pixels = ddsd.lpSurface; return(0); } @@ -2107,6 +2112,9 @@ if ( surface->hwdata ) { if ( surface->hwdata->dd_surface != SDL_primary ) { IDirectDrawSurface3_Release(surface->hwdata->dd_surface); + } + if ( surface->hwdata->buffer ) { + SDL_free(surface->hwdata->buffer); } SDL_free(surface->hwdata); surface->hwdata = NULL;