Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp

Issue 1657593003: Carefully handle large end time values in AudioParam automations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add test Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
index 3954f121531c1dbed524d9ce6d377c7e4ed0e7f6..4f120b5bb65cceb6e9da08b792a657024302dbe2 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -421,7 +421,14 @@ float AudioParamTimeline::valuesForFrameRangeImpl(
// (assuming sampleRate = 1). Since time2 is greater than 128, we want to output a value
// for frame 128. This requires that fillToEndFrame be at least 129. This is achieved by
// ceil(time2).
- size_t fillToEndFrame = std::min(endFrame, static_cast<size_t>(ceil(time2 * sampleRate)));
+ //
+ // However, time2 can be very large, so compute this carefully in the case where time2
+ // exceeds the size of a size_t.
+
+ size_t fillToEndFrame = endFrame;
+ if (endFrame > time2 * sampleRate)
+ fillToEndFrame = static_cast<size_t>(ceil(time2 * sampleRate));
+
ASSERT(fillToEndFrame >= startFrame);
size_t fillToFrame = fillToEndFrame - startFrame;
fillToFrame = std::min(fillToFrame, static_cast<size_t>(numberOfValues));

Powered by Google App Engine
This is Rietveld 408576698