Uploaded image for project: 'Qt Safe Renderer'
  1. Qt Safe Renderer
  2. QSR-2808

QSafeBitmapResource::scanline(const qint32 pixelRow) should take unsigned argument

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • QSR 3.0
    • QSR 3.0
    • Runtime
    • None
    • b846d96a0 (dev)

    Description

      Function scanline in QSafeBitmapResource takes signed values, which can lead to uninformed programmer to give a negative value that the function does not check for:

      const ARGB *QSafeBitmapResource::scanline(const qint32 pixelRow) const
      {
          const bool isAccessOK = (m_data != nullptr) && (pixelRow < height());
          const ARGB *argbPtr = nullptr;
          if (isAccessOK) {
              // AXIVION Next Line MisraC++2023-8.2.5: Unavoidable cast to unrelated pointer type. The m_data is 4-byte aligned and is safe to convert to ARGB.
              argbPtr = reinterpret_cast<const ARGB*>(&m_data[pixelRow * width()]);
          }
          return argbPtr;
      }
      

      Either make pixelRow a quint32, or add a lower bound check for it.

      Attachments

        For Gerrit Dashboard: QSR-2808
        # Subject Branch Project Status CR V

        Activity

          People

            jussi_witick Jussi Witick
            jussi_witick Jussi Witick
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes