SCI32: Fix invalid memory access after BitmapTable is extended
When new bitmaps are added and the underlying Common::Array needs to move to expand, this invalidates all pointers to bitmaps, which makes it basically impossible to use the bitmap segment since you never know if a reference is going to be invalidated due to an array move. To solve this, BitmapTable is changed to hold pointers to SciBitmaps that are allocated separately on the heap instead, so when those bitmaps are looked up, the resulting pointers are valid for the lifetime of the bitmap, instead of the lifetime of the Common::Array used internally by BitmapTable.
This commit is contained in:
parent
10f9cb7023
commit
6d1f8e8c87
5 changed files with 77 additions and 30 deletions
|
@ -313,17 +313,6 @@ SegmentRef StringTable::dereference(reg_t pointer) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Bitmaps
|
||||
|
||||
SegmentRef BitmapTable::dereference(reg_t pointer) {
|
||||
SegmentRef ret;
|
||||
ret.isRaw = true;
|
||||
ret.maxSize = at(pointer.getOffset()).getRawSize();
|
||||
ret.raw = at(pointer.getOffset()).getRawData();
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
} // End of namespace Sci
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue