WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
246406
[WTF] MediaTime: assert not double in timeValue() and timeScale()
https://bugs.webkit.org/show_bug.cgi?id=246406
Summary
[WTF] MediaTime: assert not double in timeValue() and timeScale()
Alicia Boya García
Reported
2022-10-12 09:19:06 PDT
A MediaTime can either represent a time as a fraction or as a floating point number. Both representations are stored in a union, with a tag in m_timeFlags to know which one must be used. timeValue() and timeScale() are the methods used to get the numerator and denominator of the time when a MediaTime is fractional. However, as the code stood before this patch, there is no check (even in Debug mode) to assert this is the case. An accidental use of timeValue() in this situation would return an int64_t with the bit contents of an IEEE 754 double, which could cause a hard to debug bug. Similarly, timeScale() is undefined in this case. This code adds an assert to both methods to guard against accidental usages on MediaTime instances containing floating point values. Additionally: these functions used to return references. Doing so exposes implementation details of MediaTime and would enable dangerous and confusing uses (e.g. calling timeValue() first, saving it in a reference variable, updating the MediaTime and checking the variable afterwards). All existing uses are as an immediate, so they can be safely refactored to return by value, which is safer. * Source/WTF/wtf/MediaTime.h:
Attachments
Add attachment
proposed patch, testcase, etc.
Alicia Boya García
Comment 1
2022-10-19 03:16:11 PDT
Pull request:
https://github.com/WebKit/WebKit/pull/5533
Radar WebKit Bug Importer
Comment 2
2022-10-19 09:20:38 PDT
<
rdar://problem/101340439
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug