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

nullptr dereference when deleting a QMqttSubscription

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.3
    • MQTT
    • None

    Description

      Scenario: subscribing an MQTT topic for a certain duration, using QMqttSubscription's destructor instead of its unsubscribe() method.

      The bug: the QMqttConnection class keeps references to the destroyed object beyond its lifetime, leading to a segfault.

      Here's a simple way to reproduce (it needs an active broker running on localhost):

      #include "qmqttclient.h"
      
      int main(int argc, char *argv[])
      {
          QCoreApplication app(argc, argv);
          auto *client = new QMqttClient(&app);
          client->setHostname("localhost");
          client->setPort(1883);
          client->setClientId(QCoreApplication::applicationName());
          client->connectToHost();
          QObject::connect(client, &QMqttClient::connected, client, [client] {
              auto *sub = client->subscribe({ "temporaryinterest" }, 0);
              QTimer::singleShot(100, [sub]() { delete sub; });
          });
          return app.exec();
      }

      Attachments

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

        Activity

          People

            mkalinow Maurice Kalinowski
            beku-epitome Benedek Kupper
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes