Skip to content

Commit

Permalink
To avoid zero-vector begin iterator dereference (this is undefined be…
Browse files Browse the repository at this point in the history
…haviour as zero-vector begin==end).
  • Loading branch information
intorr committed Dec 8, 2017
1 parent 45f50b9 commit 7c45ae8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/xrEngine/pure.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class CRegistrator // the registrator itself
};
void Resort(void)
{
qsort(&*R.begin(), R.size(), sizeof(_REG_INFO), _REG_Compare);
if (R.size())
qsort(&*R.begin(), R.size(), sizeof(_REG_INFO), _REG_Compare);
while ((R.size()) && (R[R.size() - 1].Prio == REG_PRIORITY_INVALID))
R.pop_back();
if (R.empty())
Expand Down
3 changes: 2 additions & 1 deletion src/xrGame/NET_Queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class NET_Event
}
void implication(NET_Packet& P) const
{
CopyMemory(P.B.data, &*data.begin(), (u32)data.size());
if (data.size())
CopyMemory(P.B.data, &*data.begin(), (u32)data.size());
P.B.count = (u32)data.size();
P.r_pos = 0;
}
Expand Down

0 comments on commit 7c45ae8

Please sign in to comment.