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
This commit is contained in:
Sam Lantinga 2001-07-12 23:34:44 +00:00
parent 76b5d94d9d
commit c3aaf60a7d

View file

@ -740,11 +740,12 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface)
vidmem_bucket *bucket, *freeable;
/* Look for the bucket in the current list */
bucket = (vidmem_bucket *)surface->hwdata;
if ( (bucket == NULL) || ! bucket->used ) {
return;
for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
if ( bucket == (vidmem_bucket *)surface->hwdata ) {
break;
}
}
if ( bucket && bucket->used ) {
/* Add the memory back to the total */
#ifdef DGA_DEBUG
printf("Freeing bucket of %d bytes\n", bucket->size);
@ -777,6 +778,7 @@ static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface)
}
free(freeable);
}
}
surface->pixels = NULL;
surface->hwdata = NULL;
}