Skip to content

Commit 48b8440

Browse files
authored
Ebenezer: Ensure region buffer exists (#806)
This may not be initialized at the time it's referenced by the SendWorkerThread. Just be safe.
1 parent 66354ab commit 48b8440

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Server/Ebenezer/User.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,10 @@ void CUser::SendCompressingPacket(const char* pData, int len)
285285

286286
void CUser::RegionPacketAdd(char* pBuf, int len)
287287
{
288+
assert(_regionBuffer != nullptr);
289+
if (_regionBuffer == nullptr)
290+
return;
291+
288292
std::lock_guard<std::recursive_mutex> lock(g_region_mutex);
289293

290294
SetShort(_regionBuffer->pDataBuff, len, _regionBuffer->iLength);
@@ -294,14 +298,14 @@ void CUser::RegionPacketAdd(char* pBuf, int len)
294298
int CUser::RegionPacketClear(char* GetBuf)
295299
{
296300
int index = 0;
297-
SetByte(GetBuf, WIZ_CONTINOUS_PACKET, index);
298301

299302
{
300303
std::lock_guard<std::recursive_mutex> lock(g_region_mutex);
301304

302-
if (_regionBuffer->iLength <= 0)
305+
if (_regionBuffer == nullptr || _regionBuffer->iLength <= 0)
303306
return 0;
304307

308+
SetByte(GetBuf, WIZ_CONTINOUS_PACKET, index);
305309
SetShort(GetBuf, _regionBuffer->iLength, index);
306310
SetString(GetBuf, _regionBuffer->pDataBuff, _regionBuffer->iLength, index);
307311

0 commit comments

Comments
 (0)