Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(video): fix a use-after-free with VideoFrame
Browse files Browse the repository at this point in the history
  • Loading branch information
initramfs committed Aug 3, 2016
1 parent 8ef89a2 commit 8487dce
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/video/videoframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8487dce

Please sign in to comment.