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

MemorySanitizer: use-of-uninitialized-value: checkForAlphaPixels triggers uninitialized value after QImage::fill on arm build

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 5.12.2
    • Image formats
    • None
    • Linux/Other display system

    Description

      Minimial repro:

       
       

      QImageimage(4, 4, QImage::Format_ARGB32_Premultiplied);
      image.fill(0);
      image.data_ptr()->checkForAlphaPixels();

       
       
      triggers: "SUMMARY: MemorySanitizer: use-of-uninitialized-value image/qimage.cpp:195:9 in QImageData::checkForAlphaPixels() const"
       
      when it accesses the `bits` in the block

      {{}}

      case QImage::Format_ARGB32_Premultiplied: { 
        const uchar *bits = data;
        for (int y=0; y<height && !has_alpha_pixels; ++y) {
         uint alphaAnd = 0xff000000;
         for (int x=0; x<width; ++x)
           alphaAnd &= reinterpret_cast<const uint*>(bits)[x];
         has_alpha_pixels = (alphaAnd != 0xff000000);bits += bytes_per_line;
         }
       }
       break;

       
       
      The simplest fix I've found is to initialize the QIamgeData.data member with `calloc` instead of `malloc`:

       

       QImageData * QImageData::create(const QSize &size, QImage::Format format)
      {
        [...]
        d->data = (uchar *)calloc(d->nbytes, 1);
        [...]
       } 

       

      Attachments

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

        Activity

          People

            vgt Eirik Aavitsland
            mbjorge Michael Bjorge
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes