edbee-lib icon indicating copy to clipboard operation
edbee-lib copied to clipboard

USE_AFTER_FREE in TextRenderer::textLayoutForLineForPlaceholder(int)

Open vadi2 opened this issue 4 years ago • 2 comments

Coverity is pointing out the following with the new placeholder code:

New defect(s) Reported-by: Coverity Scan
Showing 2 of 2 defect(s)


** CID 1495409:  Memory - illegal accesses  (USE_AFTER_FREE)
/home/travis/build/Mudlet/Mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 300 in edbee::TextRenderer::textLayoutForLineForPlaceholder(int)()


________________________________________________________________________________________________________
*** CID 1495409:  Memory - illegal accesses  (USE_AFTER_FREE)
/home/travis/build/Mudlet/Mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 300 in edbee::TextRenderer::textLayoutForLineForPlaceholder(int)()
294     
295             // add to the cache
296             cachedTextLayoutList_.insert( line, textLayout );
297     //qlog_info() << "Cache Line: " << line;
298     
299         }
>>>     CID 1495409:  Memory - illegal accesses  (USE_AFTER_FREE)
>>>     Using freed pointer "textLayout".
300         return textLayout;
301     }
302     
303     QTextLayout *TextRenderer::textLayoutForLineNormal(int line)
304     {
305         Q_ASSERT( line >= 0 );

** CID 1495408:  Memory - illegal accesses  (USE_AFTER_FREE)
/home/travis/build/Mudlet/Mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 366 in edbee::TextRenderer::textLayoutForLineNormal(int)()


________________________________________________________________________________________________________
*** CID 1495408:  Memory - illegal accesses  (USE_AFTER_FREE)
/home/travis/build/Mudlet/Mudlet/3rdparty/edbee-lib/edbee-lib/edbee/views/textrenderer.cpp: 366 in edbee::TextRenderer::textLayoutForLineNormal(int)()
360             // add to the cache
361             cachedTextLayoutList_.insert( line, textLayout );
362     
363     //qlog_info() << "Cache Line: " << line;
364     
365         }
>>>     CID 1495408:  Memory - illegal accesses  (USE_AFTER_FREE)
>>>     Using freed pointer "textLayout".
366         return textLayout;
367     }
368     
369     
370     /// This method starts rendering
371     void TextRenderer::renderBegin( const QRect& rect )

vadi2 avatar Jun 02 '20 04:06 vadi2

This issue also happens in the function 'textLayoutForLineNormal' ...

Did you have this issue also before the placeholders? Because the order of malloc/dealllocs isn't changed by this.

gamecreature avatar Jun 02 '20 05:06 gamecreature

Could have been there before - Coverity might have picked this up just because this code was changed. It does some weird caching.

vadi2 avatar Jun 02 '20 05:06 vadi2