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

[cppcheck] [./qtbase/src/plugins/accessible/widgets/itemviews.cpp:746]: (error) Possible null pointer dereference: header

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.0.0 Beta 2
    • 5.0.0
    • None
    • qtbase 8e943bbf5de795d3bffbe843f5ddb26b6943317b
    • 642867d2ddae37bdf756e1466ba723b6b7f4e844

    Description

      cppcheck reports the following issue:

      [cppcheck] [./qtbase/src/plugins/accessible/widgets/itemviews.cpp:746]: (error) Possible null pointer dereference: header
      

      Here's the entirety of the function it's complaining about:

      QRect QAccessibleTableHeaderCell::rect() const
      {
          QHeaderView *header = 0;
          if (false) {
      #ifndef QT_NO_TABLEVIEW
          } else if (const QTableView *tv = qobject_cast<const QTableView*>(view)) {
              if (orientation == Qt::Horizontal) {
                  header = tv->horizontalHeader();
              } else {
                  header = tv->verticalHeader();
              }
      #endif
      #ifndef QT_NO_TREEVIEW
          } else if (const QTreeView *tv = qobject_cast<const QTreeView*>(view)) {
              header = tv->header();
      #endif
          }
          QPoint zero = header->mapToGlobal(QPoint(0, 0));
          int sectionSize = header->sectionSize(index);
          int sectionPos = header->sectionPosition(index);
          return orientation == Qt::Horizontal
                  ? QRect(zero.x() + sectionPos, zero.y(), sectionSize, header->height())
                  : QRect(zero.x(), zero.y() + sectionPos, header->width(), sectionSize);
      }
      

      I'm not 100% sure if the complaint is valid, but it certainly seems possible that header could be 0 at the header->mapToGlobal().

      Attachments

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

        Activity

          People

            frederik Frederik Gladhorn
            rmcgover Rohan McGovern (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes