Skip to content

Commit

Permalink
Fix potential stack overflow in CRender::LoadBuffers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 9, 2014
1 parent ed73dea commit a5525d2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Layers/xrRenderPC_R4/r4_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,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 a5525d2

Please sign in to comment.