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:
parent
76b5d94d9d
commit
c3aaf60a7d
1 changed files with 25 additions and 23 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue