Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7199

Qt application crash when trying to delete Qimage Format_RGB888

$
0
0

I get a "HEAP CORRUPTION DETECTED: After normal block ... CRT detected that the application wrote to memory after end of heap buffer." when variable test gets destroyed.If I change the image size, the crash does not occur, I'm thinking it has something to do with memory alignment, but I cannot figure out what.

I am using the official Qt builds for MSVC 2017 64bit

#include <QCoreApplication>#include <QImage>QImage foo(int width, int height){    QImage retVal(width, height, QImage::Format_RGB888);    for (int i = 0; i < height; ++i) // read each line of the image    {        QRgb *lineBuf = reinterpret_cast<QRgb *>(retVal.scanLine(i));        for (int j = 0; j < width; ++j)        {            lineBuf[j] = qRgb(0,0,0);        }    }    return retVal;}int main(int argc, char *argv[]){    QCoreApplication a(argc, argv);    {        QImage test = foo(5,5);    }    return a.exec();}

Viewing all articles
Browse latest Browse all 7199

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>