Details
-
Bug
-
Resolution: Invalid
-
Not Evaluated
-
None
-
5.14.1
-
None
-
Windows 10 x64
Description
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.
#include <QGuiApplication> #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[]) { QGuiApplication a(argc, argv); { QImage test = foo(5,5); } return a.exec(); }