From 9e8a66a0a37cfd5b45aed47174775ef4ca95d8ab Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 12 Jan 2020 21:30:30 +0000 Subject: [PATCH] Don't try to clear memory if the bitmap has an invalid size. --- qa/qa_utils/mocks.cpp | 31 +++++++++++++++++------------ thirdparty/potrace/include/bitmap.h | 3 ++- thirdparty/potrace/src/greymap.cpp | 5 +++-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/qa/qa_utils/mocks.cpp b/qa/qa_utils/mocks.cpp index 676265b4c8..e2360b2b75 100644 --- a/qa/qa_utils/mocks.cpp +++ b/qa/qa_utils/mocks.cpp @@ -176,21 +176,26 @@ void DIALOG_FIND::onClose( wxCommandEvent& aEvent ) } -DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_FIND_BASE::DIALOG_FIND_BASE( wxWindow* parent, wxWindowID id, const wxString& title, + const wxPoint& pos, const wxSize& size, long style ) : + DIALOG_SHIM( parent, id, title, pos, size, style ) { // these members are initialized only to avoid warnings about non initialized vars - /* - m_staticText1 = nullptr; - m_SearchCombo = nullptr; - m_button1 = nullptr; - m_button2 = nullptr; - m_button3 = nullptr; - */ + searchStringLabel = nullptr; + m_searchCombo = nullptr; + m_matchCase = nullptr; + m_matchWords = nullptr; + m_wildcards = nullptr; + m_wrap = nullptr; + m_includeValues = nullptr; + m_includeReferences = nullptr; + m_includeTexts = nullptr; + m_includeMarkers = nullptr; + m_includeVias = nullptr; + m_findNext = nullptr; + m_findPrevious = nullptr; + m_searchAgain = nullptr; + m_closeButton = nullptr; } diff --git a/thirdparty/potrace/include/bitmap.h b/thirdparty/potrace/include/bitmap.h index bc5f945c5b..e1765e08a9 100644 --- a/thirdparty/potrace/include/bitmap.h +++ b/thirdparty/potrace/include/bitmap.h @@ -161,7 +161,8 @@ static inline void bm_clear( potrace_bitmap_t* bm, int c ) * guaranteed that size will fit into the ptrdiff_t type. */ ptrdiff_t size = bm_size( bm ); - memset( bm_base( bm ), c ? -1 : 0, size ); + if( size > 0 ) + memset( bm_base( bm ), c ? -1 : 0, size ); } diff --git a/thirdparty/potrace/src/greymap.cpp b/thirdparty/potrace/src/greymap.cpp index 88e7641f42..8e7f812fd4 100644 --- a/thirdparty/potrace/src/greymap.cpp +++ b/thirdparty/potrace/src/greymap.cpp @@ -159,7 +159,8 @@ void gm_clear( greymap_t* gm, int b ) if( b == 0 ) { - memset( gm->base, 0, size ); + if( size > 0 ) + memset( gm->base, 0, size ); } else { @@ -176,7 +177,7 @@ void gm_clear( greymap_t* gm, int b ) /* turn the given greymap upside down. This does not move the pixel * data or change the base address. */ -static inline void gm_flip( greymap_t* gm ) +static inline void GM_FLIP( greymap_t* gm ) { int dy = gm->dy;