Skip to content

Commit 9cbf5b6

Browse files
Use std::clamp for framesRead bounds check per code review suggestion
Agent-Logs-Url: https://github.com/winnerspiros/osu/sessions/93c72c6f-5cbd-4c16-9016-6f040b2bea62 Co-authored-by: winnerspiros <1675249+winnerspiros@users.noreply.github.com>
1 parent 7ea1093 commit 9cbf5b6

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

osu.Android/Native/oboe_bridge.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ oboe::DataCallbackResult OboeBridge::onAudioReady(
257257

258258
// Clamp to valid range: negative or out-of-range values from the provider
259259
// would wrap to a huge size_t, causing a buffer overrun in the memset below.
260-
if (framesRead < 0) framesRead = 0;
261-
if (framesRead > numFrames) framesRead = numFrames;
260+
framesRead = std::clamp(framesRead, 0, numFrames);
262261

263262
if (framesRead < numFrames) {
264263
size_t bytesDone = static_cast<size_t>(framesRead) * stream->getChannelCount() * sizeof(float);

0 commit comments

Comments
 (0)