Skip to content

Commit

Permalink
Some additional safety checks for global map loading
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Feb 1, 2014
1 parent f89b3ca commit dea9d21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/openmw/mwrender/globalmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ namespace MWRender
if (bounds.mMaxY-bounds.mMinY <= 0)
return;

if (bounds.mMinX > bounds.mMaxX
|| bounds.mMinY > bounds.mMaxY)
throw std::runtime_error("invalid map bounds");

Ogre::Image image;
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&map.mImageData[0], map.mImageData.size()));
image.load(stream, "png");
Expand Down Expand Up @@ -297,9 +301,15 @@ namespace MWRender
// If cell bounds of the currently loaded content and the loaded savegame do not match,
// we need to resize source/dest boxes to accommodate
// This means nonexisting cells will be dropped silently

int cellImageSizeDst = 24;

// Completely off-screen? -> no need to blit anything
if (bounds.mMaxX < mMinX
|| bounds.mMaxY < mMinY
|| bounds.mMinX > mMaxX
|| bounds.mMinY > mMaxY)
return;

int leftDiff = (mMinX - bounds.mMinX);
int topDiff = (bounds.mMaxY - mMaxY);
int rightDiff = (bounds.mMaxX - mMaxX);
Expand Down

0 comments on commit dea9d21

Please sign in to comment.