From c560449fbf490aaa3db9c63beb909ae0cbc64f63 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Mon, 18 Dec 2017 23:25:45 +0000 Subject: [PATCH] Add some code protection into FrameCrop module --- modules/FrameCrop.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/FrameCrop.cpp b/modules/FrameCrop.cpp index a67b35d..adde284 100644 --- a/modules/FrameCrop.cpp +++ b/modules/FrameCrop.cpp @@ -50,14 +50,14 @@ FrameCrop::FrameCrop() Void FrameCrop::create( PlaYUVerFrame* frame ) { m_pcCropedFrame = NULL; - if( m_iXSize == -1 ) - { + if( m_uiXPosition >= frame->getWidth() ) + m_uiXPosition = 0; + if( m_uiYPosition >= frame->getHeight() ) + m_uiXPosition = 0; + if( m_iXSize == -1 || ( m_uiXPosition + m_iXSize ) >= frame->getWidth() ) m_iXSize = frame->getWidth() - m_uiXPosition; - } - if( m_iYSize == -1 ) - { + if( m_iYSize == -1 || ( m_uiYPosition + m_iYSize ) >= frame->getHeight() ) m_iYSize = frame->getHeight() - m_uiYPosition; - } m_pcCropedFrame = new PlaYUVerFrame( m_iXSize, m_iYSize, frame->getPelFormat(), frame->getBitsPel() ); }