Save a shallow copy of an original image
The app crashes when trying to get an image from a document using document->image()
. Looks like it can be destroyed from another thread so we should make a shallow copy of it. It's fast and fixes the crash.
=================================================================
==2819==ERROR: AddressSanitizer: heap-use-after-free on address 0x7ebf99e5c800 at pc 0x7effdfa5f519 bp 0x7ffefa13e790 sp 0x7ffefa13df38
READ of size 6404 at 0x7ebf99e5c800 thread T0
#0 0x7effdfa5f518 in __interceptor_memcpy /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:827
#1 0x7effdc98e98f in QImage::copy(QRect const&) const (/usr/lib/libQt5Gui.so.5+0x18e98f)
#2 0x7effdf6f04a8 in Gwenview::RasterImageItem::paint(QPainter*, QStyleOptionGraphicsItem const*, QWidget*) /home/archie/kde/src/gwenview/lib/documentview/rasterimageitem.cpp:105
0x7ebf99e5c800 is located 0 bytes inside of 16400644-byte region [0x7ebf99e5c800,0x7ebf9ae00904)
freed by thread T28 (Thread (pooled)) here:
#0 0x7effdfabe672 in __interceptor_free /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:52
#1 0x7effdc98576d in QImageData::~QImageData() (/usr/lib/libQt5Gui.so.5+0x18576d)
#2 0x603000feffff (<unknown module>)
Edited by Nikita Karpei