Skip to content

Commit 2418a49

Browse files
committed
Re-add dummy, cast to void
1 parent 96695e2 commit 2418a49

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

core/sourcehook/sh_memory.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,11 @@ namespace SourceHook
322322
prevHandler = signal(SIGSEGV, BadReadHandler);
323323

324324
volatile const char *p = reinterpret_cast<const char*>(addr);
325+
char dummy;
326+
325327
for (size_t i = 0; i < len; i++)
326-
p[i];
328+
dummy = p[i];
329+
(void)dummy; // silence unused var, we must read from p
327330

328331
g_BadReadCalled = false;
329332

@@ -344,8 +347,11 @@ namespace SourceHook
344347
return false;
345348

346349
volatile const char *p = reinterpret_cast<const char *>(addr);
350+
char dummy;
351+
347352
for (size_t i = 0; i < len; i++)
348-
p[i];
353+
dummy = p[i];
354+
(void)dummy; // silence unused var, we must read from p
349355

350356
g_BadReadCalled = false;
351357

0 commit comments

Comments
 (0)