Skip to content

Commit af29864

Browse files
committed
Defensive code fix to prevent out of bounds memory copy in GetElementPtr
1 parent 3bafceb commit af29864

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

renderdoc/driver/shaders/dxil/dxil_debug.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4258,12 +4258,17 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
42584258

42594259
result.type = baseType;
42604260
result.rows = (uint8_t)countElems;
4261-
backingMemory += offset;
4262-
m_Memory.m_AllocPointers[resultId] = {ptrId, backingMemory, size};
42634261

42644262
RDCASSERT(offset + size <= alloc.size);
4265-
RDCASSERT(size < sizeof(result.value.f32v));
4266-
memcpy(&result.value.f32v[0], backingMemory, size);
4263+
if(offset + size <= alloc.size)
4264+
{
4265+
backingMemory += offset;
4266+
m_Memory.m_AllocPointers[resultId] = {ptrId, backingMemory, size};
4267+
4268+
RDCASSERT(size < sizeof(result.value.f32v));
4269+
if(size < sizeof(ShaderValue))
4270+
memcpy(&result.value.f32v[0], backingMemory, size);
4271+
}
42674272
break;
42684273
}
42694274
case Operation::Bitcast:

0 commit comments

Comments
 (0)