Closed Bug 1298275 Opened 10 years ago Closed 10 years ago

FlacFrameParser's AutoByteReader has a virtual destructor when its superclass doesn't

Categories

(Core :: Audio/Video: Playback, defect, P3)

50 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla51
Tracking Status
firefox51 --- fixed

People

(Reporter: mozbugz, Assigned: mozbugz)

References

Details

Attachments

(1 file)

ByteReader's destructor is not virtual. AutoByteReader inherits from ByteReader, but declares its destructor virtual. AutoByteReader is only used as a stack object in FlacFrameParser.cpp, so it's not a big problem at the moment, just a bit wasteful. But if it was exposed to a wider audience (e.g., after bug 1298271), this could be ripe for abuse, e.g., if an AutoByteReader was stored in a pointer-to-ByteReader, the wrong destructor would be called. So either we can make ~ByteReader virtual too, or make both non-virtual if we can ensure AutoByteReader won't get stored into a ByteReader*.
Assignee: nobody → gsquelart
Comment on attachment 8785183 [details] Bug 1298275 - Make ~AutoByteReader non-virtual - https://reviewboard.mozilla.org/r/74480/#review72344 ::: media/libstagefright/binding/include/mp4_demuxer/ByteReader.h:19 (Diff revision 1) > > +MOZ_RAII > class ByteReader > { > public: > ByteReader() : mPtr(nullptr), mRemaining(0) {} Wouldn't it be easier to mark ~ByteReader as virtual?
Attachment #8785183 - Flags: review?(jyavenard) → review+
Comment on attachment 8785183 [details] Bug 1298275 - Make ~AutoByteReader non-virtual - https://reviewboard.mozilla.org/r/74480/#review72344 Thank you for the quick review. > Wouldn't it be easier to mark ~ByteReader as virtual? But it would be so inefficient! Also ByteReader points at an external buffer, so enforcing it to be an on-stack object prevents it being stored somewhere where it could outlive the external buffer.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla51
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: