mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(video): fix a use-after-free with VideoFrame
This commit is contained in:
parent
8ef89a267e
commit
8487dcecf8
|
@ -90,7 +90,7 @@ QReadWriteLock VideoFrame::refsLock {};
|
|||
* @param freeSourceFrame whether to free the source frame buffers or not.
|
||||
*/
|
||||
VideoFrame::VideoFrame(IDType sourceID, AVFrame* sourceFrame, QRect dimensions, int pixFmt, bool freeSourceFrame)
|
||||
: frameID(frameIDs.fetch_add(std::memory_order_relaxed)),
|
||||
: frameID(frameIDs++),
|
||||
sourceID(sourceID),
|
||||
sourceDimensions(dimensions),
|
||||
sourcePixelFormat(pixFmt),
|
||||
|
@ -483,6 +483,11 @@ void VideoFrame::storeAVFrame(AVFrame* frame, const QSize& dimensions, const int
|
|||
*/
|
||||
void VideoFrame::deleteFrameBuffer()
|
||||
{
|
||||
// An empty framebuffer represents a frame that's already been freed
|
||||
if(frameBuffer.empty()){
|
||||
return;
|
||||
}
|
||||
|
||||
for(const auto& frameIterator : frameBuffer)
|
||||
{
|
||||
AVFrame* frame = frameIterator.second;
|
||||
|
|
Loading…
Reference in New Issue
Block a user