Skip to content

Commit

Permalink
CachedInterpreterEmitter: Fix std::memcpy UB
Browse files Browse the repository at this point in the history
I wasn't aware that even with a size of zero, it's still not safe to pass a nullptr to `std::memcpy`. When `CachedInterpreterEmitter::PoisonCallback` is written, UB is happening.
  • Loading branch information
mitaclaw committed Sep 2, 2024
1 parent 7d08377 commit 5a95c5d
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void CachedInterpreterEmitter::Write(AnyCallback callback, const void* operands,
}
std::memcpy(m_code, &callback, sizeof(callback));
m_code += sizeof(callback);
if (size == 0)
return;
std::memcpy(m_code, operands, size);
m_code += size;
}
Expand Down

0 comments on commit 5a95c5d

Please sign in to comment.