Closed
Bug 1276140
Opened 8 years ago
Closed 8 years ago
Avoid undefined behavior in frame properties table
Categories
(Core :: Layout, defect)
Core
Layout
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: xidorn, Assigned: xidorn)
Details
Attachments
(1 file)
The current method that using union to reinterpret value is actually an undefined behavior per C++ spec, since it requires to access inactive union member. Although many compilers implement a language extension to allow that, we may still want to avoid undefined behavior as much as possible. Using memcpy is the safest way to do reinterpreting between unknown types, and most compilers are able to optimize it properly when possible.
Assignee | ||
Updated•8 years ago
|
Assignee: nobody → bugzilla
Assignee | ||
Comment 1•8 years ago
|
||
Review commit: https://reviewboard.mozilla.org/r/55682/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/55682/
Attachment #8757140 -
Flags: review?(nfroyd)
![]() |
||
Updated•8 years ago
|
Attachment #8757140 -
Flags: review?(nfroyd) → review+
![]() |
||
Comment 2•8 years ago
|
||
Comment on attachment 8757140 [details] MozReview Request: Bug 1276140 - Use memcpy rather than union to reinterpret in frame properties table. r?froydnj https://reviewboard.mozilla.org/r/55682/#review52462 r=me with the changes below. ::: layout/base/FramePropertyTable.h:298 (Diff revision 1) > + template<typename T> > + struct ReinterpretHelper<T*> > + { > + static void* ToPointer(T* aValue) > + { > + return reinterpret_cast<void*>(aValue); Casts to and from void pointers can be static_cast, here and below.
Assignee | ||
Comment 3•8 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/bc8ea177c0d8303861f04c6009582acf40c692bb Bug 1276140 - Use memcpy rather than union to reinterpret in frame properties table. r=froydnj
Comment 4•8 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bc8ea177c0d8
Status: NEW → RESOLVED
Closed: 8 years ago
status-firefox49:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•