Skip to content

Commit 7c45ae8

Browse files
committed
To avoid zero-vector begin iterator dereference (this is undefined behaviour as zero-vector begin==end).
1 parent 45f50b9 commit 7c45ae8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/xrEngine/pure.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ class CRegistrator // the registrator itself
114114
};
115115
void Resort(void)
116116
{
117-
qsort(&*R.begin(), R.size(), sizeof(_REG_INFO), _REG_Compare);
117+
if (R.size())
118+
qsort(&*R.begin(), R.size(), sizeof(_REG_INFO), _REG_Compare);
118119
while ((R.size()) && (R[R.size() - 1].Prio == REG_PRIORITY_INVALID))
119120
R.pop_back();
120121
if (R.empty())

src/xrGame/NET_Queue.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class NET_Event
6565
}
6666
void implication(NET_Packet& P) const
6767
{
68-
CopyMemory(P.B.data, &*data.begin(), (u32)data.size());
68+
if (data.size())
69+
CopyMemory(P.B.data, &*data.begin(), (u32)data.size());
6970
P.B.count = (u32)data.size();
7071
P.r_pos = 0;
7172
}

0 commit comments

Comments
 (0)