Skip to content

Commit

Permalink
Fix potential stack overflow in CRender::LoadBuffers (R3).
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 9, 2014
1 parent a5525d2 commit 43536dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Layers/xrRenderPC_R3/r3_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ void CRender::LoadBuffers (CStreamReader *base_fs, BOOL _alternative)
u32 count = fs->r_u32();
_DC.resize (count);
_VB.resize (count);
u32 bufferSize = (MAXD3DDECLLENGTH+1)*sizeof(D3DVERTEXELEMENT9);
D3DVERTEXELEMENT9* dcl = (D3DVERTEXELEMENT9*)_alloca(bufferSize);
for (u32 i=0; i<count; i++)
{
// decl
// D3DVERTEXELEMENT9* dcl = (D3DVERTEXELEMENT9*) fs().pointer();
u32 buffer_size = (MAXD3DDECLLENGTH+1)*sizeof(D3DVERTEXELEMENT9);
D3DVERTEXELEMENT9 *dcl = (D3DVERTEXELEMENT9*)_alloca(buffer_size);
fs->r (dcl,buffer_size);
fs->advance (-(int)buffer_size);
fs->r (dcl,bufferSize);
fs->advance (-(int)bufferSize);

u32 dcl_len = D3DXGetDeclLength (dcl)+1;
_DC[i].resize (dcl_len);
Expand Down

0 comments on commit 43536dc

Please sign in to comment.