Commit 9bf70365 by Jamie Madill

Fix a possible OOB read in InsertD3D11FormatInfo.

It's unclear how this might happen, as it's during static map init, but add a fail-safe to be sure. BUG=526779 Change-Id: I5aa33f9bed30d4a8c1e9937a0b8c5fd11a7503d7 Reviewed-on: https://chromium-review.googlesource.com/302385Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tryjob-Request: Jamie Madill <jmadill@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 16a79cd1
...@@ -173,13 +173,18 @@ inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *formatMap, ...@@ -173,13 +173,18 @@ inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *formatMap,
static const SwizzleInfoMap &swizzleMap = BuildSwizzleInfoMap(); static const SwizzleInfoMap &swizzleMap = BuildSwizzleInfoMap();
SwizzleInfoMap::const_iterator swizzleIter = SwizzleInfoMap::const_iterator swizzleIter =
swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType)); swizzleMap.find(SwizzleSizeType(maxBits, formatInfo.componentType));
ASSERT(swizzleIter != swizzleMap.end());
// Handle the odd case where we might find an invalid swizzle key.
// This should never happen, but it's hard to prove, so add a fail-safe.
ASSERT(swizzleIter != swizzleMap.end());
if (swizzleIter != swizzleMap.end())
{
const SwizzleFormatInfo &swizzleInfo = swizzleIter->second; const SwizzleFormatInfo &swizzleInfo = swizzleIter->second;
info.swizzleTexFormat = swizzleInfo.mTexFormat; info.swizzleTexFormat = swizzleInfo.mTexFormat;
info.swizzleSRVFormat = swizzleInfo.mSRVFormat; info.swizzleSRVFormat = swizzleInfo.mSRVFormat;
info.swizzleRTVFormat = swizzleInfo.mRTVFormat; info.swizzleRTVFormat = swizzleInfo.mRTVFormat;
} }
}
else else
{ {
// The original texture format is suitable for swizzle operations // The original texture format is suitable for swizzle operations
......
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