Closed
Bug 1026854
Opened 10 years ago
Closed 10 years ago
We need RAII for memory management in media/libcubeb/src/cubeb_resampler.cpp
Categories
(Core :: Audio/Video, defect)
Core
Audio/Video
Tracking
()
RESOLVED
FIXED
mozilla33
People
(Reporter: jwwang, Assigned: cgg, Mentored)
References
Details
(Whiteboard: [good first bug])
Attachments
(1 file, 5 obsolete files)
4.25 KB,
patch
|
padenot
:
review+
|
Details | Diff | Splinter Review |
See bug 1008079 comment 24. This should be a good bug for the Bugzilla starter.
Reporter | ||
Updated•10 years ago
|
Assignee | ||
Comment 1•10 years ago
|
||
Assignee | ||
Comment 2•10 years ago
|
||
:-*
Attachment #8443941 -
Attachment is obsolete: true
Attachment #8443956 -
Flags: review?(paul)
Assignee | ||
Comment 3•10 years ago
|
||
:3
Attachment #8443956 -
Attachment is obsolete: true
Attachment #8443956 -
Flags: review?(paul)
Attachment #8443958 -
Flags: review?(paul)
Assignee | ||
Updated•10 years ago
|
Attachment #8443958 -
Attachment is obsolete: true
Attachment #8443958 -
Flags: review?(paul)
Comment 5•10 years ago
|
||
Comment on attachment 8443960 [details] [diff] [review] Add an utilitary class for array RAII Looks good.
Attachment #8443960 -
Flags: review?(paul) → review+
Updated•10 years ago
|
Assignee: nobody → clement.geiger
Comment 7•10 years ago
|
||
Thanks ! https://hg.mozilla.org/integration/mozilla-inbound/rev/619b13c76a5f
Comment 8•10 years ago
|
||
> , leftover_frames_buffer(auto_array<uint8_t>(frames_to_bytes(params, leftover_frame_size))) This only works because all compilers involved happen to do copy elision: http://en.wikipedia.org/wiki/Copy_elision Maybe remove the "auto_array<uint8_t>(" and declare a private and undefined copy-constructor and assignment operator to avoid the footgun?
Assignee | ||
Comment 9•10 years ago
|
||
Indeed you're completely right. I'll do that now. Thank you!
Reporter | ||
Comment 11•10 years ago
|
||
Comment on attachment 8443960 [details] [diff] [review] Add an utilitary class for array RAII Review of attachment 8443960 [details] [diff] [review]: ----------------------------------------------------------------- ::: media/libcubeb/src/cubeb_resampler.cpp @@ +17,5 @@ > +template<typename T> > +class auto_array > +{ > +public: > + auto_array(uint32_t size) Add 'explicit' to avoid confusing implicit conversion. @@ +32,5 @@ > + return data; > + } > + > +private: > + T * data; |T * const data| for const-correctness. @@ +127,4 @@ > // A little buffer to store the leftover frames, > // that is, the samples not consumed by the resampler that we will end up > // using next time fill() is called. > + auto_array<uint8_t> leftover_frames_buffer; const auto_array<> ... @@ +131,2 @@ > // A buffer to store frames that will be consumed by the resampler. > + auto_array<uint8_t> resampling_src_buffer; const auto_array<> ...
Reporter | ||
Comment 12•10 years ago
|
||
We also need one for |SpeexResamplerState *|.
Comment 13•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/619b13c76a5f
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla33
Reporter | ||
Comment 14•10 years ago
|
||
It would be a plus to have boundary check for the array class.
Assignee | ||
Comment 15•10 years ago
|
||
Hi JW, thanks for the feedback. I agree about the const. About the boundary check, I dit it at first and then realized that the [] operator was never used... so I took it out.
Reporter | ||
Comment 16•10 years ago
|
||
I think it would be nice to add some mutator functions to replace memcpy at [1] for safe array operation since we can check array boundary in those mutators. [1] http://hg.mozilla.org/mozilla-central/file/f78e532e8a10/media/libcubeb/src/cubeb_resampler.cpp#l157
Assignee | ||
Comment 17•10 years ago
|
||
Attachment #8444071 -
Attachment is obsolete: true
Attachment #8444071 -
Flags: review?(paul)
Attachment #8447493 -
Flags: review?(paul)
Assignee | ||
Comment 18•10 years ago
|
||
Comment on attachment 8447493 [details] [diff] [review] 1026854 Non.
Attachment #8447493 -
Attachment is obsolete: true
Attachment #8447493 -
Flags: review?(paul)
You need to log in
before you can comment on or make changes to this bug.
Description
•