Commit c3aaf60a authored by Sam Lantinga's avatar Sam Lantinga

Don't crash if freeing a hardware surface after the video mode has been

reset.  Fortunately we keep track of the video memory internally.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40103
parent 76b5d94d
...@@ -740,11 +740,12 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface) ...@@ -740,11 +740,12 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface)
vidmem_bucket *bucket, *freeable; vidmem_bucket *bucket, *freeable;
/* Look for the bucket in the current list */ /* Look for the bucket in the current list */
bucket = (vidmem_bucket *)surface->hwdata; for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
if ( (bucket == NULL) || ! bucket->used ) { if ( bucket == (vidmem_bucket *)surface->hwdata ) {
return; break;
} }
}
if ( bucket && bucket->used ) {
/* Add the memory back to the total */ /* Add the memory back to the total */
#ifdef DGA_DEBUG #ifdef DGA_DEBUG
printf("Freeing bucket of %d bytes\n", bucket->size); printf("Freeing bucket of %d bytes\n", bucket->size);
...@@ -777,6 +778,7 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface) ...@@ -777,6 +778,7 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface)
} }
free(freeable); free(freeable);
} }
}
surface->pixels = NULL; surface->pixels = NULL;
surface->hwdata = NULL; surface->hwdata = NULL;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment