Skip to content

Commit

Permalink
Fix crash MSG_ReadFloat
Browse files Browse the repository at this point in the history
  • Loading branch information
s1lentq committed Nov 8, 2020
1 parent f535b5b commit 543728d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion rehlds/engine/common.cpp
Expand Up @@ -1033,10 +1033,24 @@ float MSG_ReadFloat(void)
{
float f;

union
{
unsigned char b[4];
float f;
int l;
} dat;

if (msg_readcount + 4 <= net_message.cursize)
{
f = *((float*)LittleLong(*(int *)&net_message.data[msg_readcount]));
dat.b[0] = net_message.data[msg_readcount];
dat.b[1] = net_message.data[msg_readcount + 1];
dat.b[2] = net_message.data[msg_readcount + 2];
dat.b[3] = net_message.data[msg_readcount + 3];
msg_readcount += 4;

dat.l = LittleLong(dat.l);

return dat.f;
}
else
{
Expand Down

0 comments on commit 543728d

Please sign in to comment.