Skip to content

Commit a38ba88

Browse files
committed
Linux: fix some of Valgrind errors
1 parent fbe4a03 commit a38ba88

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/xrCore/NET_utils.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,71 +302,71 @@ float NET_Packet::r_float()
302302

303303
u64 NET_Packet::r_u64()
304304
{
305-
u64 A;
305+
u64 A = 0;
306306
r_u64(A);
307307
return (A);
308308
} // qword (8b)
309309

310310
s64 NET_Packet::r_s64()
311311
{
312-
s64 A;
312+
s64 A = 0;
313313
r_s64(A);
314314
return (A);
315315
} // qword (8b)
316316

317317
u32 NET_Packet::r_u32()
318318
{
319-
u32 A;
319+
u32 A = 0;
320320
r_u32(A);
321321
return (A);
322322
} // dword (4b)
323323

324324
s32 NET_Packet::r_s32()
325325
{
326-
s32 A;
326+
s32 A = 0;
327327
r_s32(A);
328328
return (A);
329329
} // dword (4b)
330330

331331
u16 NET_Packet::r_u16()
332332
{
333-
u16 A;
333+
u16 A = 0;
334334
r_u16(A);
335335
return (A);
336336
} // word (2b)
337337

338338
s16 NET_Packet::r_s16()
339339
{
340-
s16 A;
340+
s16 A = 0;
341341
r_s16(A);
342342
return (A);
343343
} // word (2b)
344344

345345
u8 NET_Packet::r_u8()
346346
{
347-
u8 A;
347+
u8 A = 0;
348348
r_u8(A);
349349
return (A);
350350
} // byte (1b)
351351

352352
s8 NET_Packet::r_s8()
353353
{
354-
s8 A;
354+
s8 A = 0;
355355
r_s8(A);
356356
return (A);
357357
}
358358

359359
void NET_Packet::r_float_q16(float& A, float min, float max)
360360
{
361-
u16 val;
361+
u16 val = 0;
362362
r_u16(val);
363363
A = (float(val) * (max - min)) / 65535.f + min; // floating-point-error possible
364364
VERIFY((A >= min - EPS_S) && (A <= max + EPS_S));
365365
}
366366

367367
void NET_Packet::r_float_q8(float& A, float min, float max)
368368
{
369-
u8 val;
369+
u8 val = 0;
370370
r_u8(val);
371371
A = (float(val) / 255.0001f) * (max - min) + min; // floating-point-error possible
372372
VERIFY((A >= min) && (A <= max));
@@ -376,7 +376,7 @@ void NET_Packet::r_angle16(float& A) { r_float_q16(A, 0, PI_MUL_2); }
376376
void NET_Packet::r_angle8(float& A) { r_float_q8(A, 0, PI_MUL_2); }
377377
void NET_Packet::r_dir(Fvector& A)
378378
{
379-
u16 t;
379+
u16 t = 0;
380380
r_u16(t);
381381
pvDecompress(A, t);
382382
}
@@ -429,7 +429,7 @@ void NET_Packet::r_stringZ(shared_str& dest)
429429
}
430430
else
431431
{
432-
string4096 buff;
432+
string4096 buff = { 0 };
433433
inistream->r_string(buff, sizeof(buff));
434434
dest = buff;
435435
}

src/xrCore/net_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class XRCORE_API NET_Packet
8787
B.count = size;
8888
}
8989

90-
NET_Buffer B;
90+
NET_Buffer B = {{0}, 0};
9191
u32 r_pos;
9292
u32 timeReceive;
9393
bool w_allow;

src/xrGame/MainMenu.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ void CMainMenu::ReadTextureInfo()
198198
* Multi-threaded ~40 ms
199199
* Just a bit of speedup
200200
*/
201-
tbb::parallel_for_each(files, [](const FS_File& file)
201+
// tbb::parallel_for_each(files, [](const FS_File& file) // Cause memory corruption (detected by Valgrind)
202+
std::for_each(files.begin(), files.end(), [](const FS_File& file)
202203
{
203204
string_path path, name;
204205
_splitpath(file.name.c_str(), nullptr, path, name, nullptr);
@@ -896,7 +897,7 @@ LPCSTR CMainMenu::GetPlayerName()
896897

897898
LPCSTR CMainMenu::GetCDKeyFromRegistry()
898899
{
899-
string512 key;
900+
string512 key = { 0 };
900901
GetCDKey_FromRegistry(key);
901902
m_cdkey._set(key);
902903
return m_cdkey.c_str();

0 commit comments

Comments
 (0)