Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85761

Potential heap corruption on QImage destruction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Invalid
    • Icon: Not Evaluated Not Evaluated
    • None
    • 5.14.1
    • GUI: Painting
    • None
    • Windows 10 x64
    • Windows

      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();
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            vgt Eirik Aavitsland
            vlad_s vlad sebesan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes