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

Windows ODBC driver, memory leak when connect failed.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.1
    • 4.8.6, 5.4.1, 5.5.1
    • SQL Support
    • None
    • bfdbfeb01233a76ea36f53c4f4be9014db5d8d86

    Description

      ODBC driver memory leak when QDatabase call open mthod failed.

      sample code:
      initialize method

      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3", QString("DB"));
      db.setDatabaseName(QString("DRIVER={SQL Server};SERVER=127.0.0.1,1433;DATABASE=TEST;UID=TEST;PWD=TEST;"));
      

      process thread

      QSqlDatabase db = QSqlDatabase::database(QString("DB"), false);
      if(!db.isOpen()) {
        if(!db.open()) {
      ...
        }
      }
      

      hEnv, hDbc resource is not release on connect or login fails.
      This problem solution, when return false, before call cleanup method.

      or... Temporary solution (without pre initiallize)

      QSqlDatabase db = QSqlDatabase::addDatabase("QODBC3", QString("DB"));
      db.setDatabaseName(QString("DRIVER={SQL Server};SERVER=127.0.0.1,1433;DATABASE=TEST;UID=TEST;PWD=TEST;"));
      
      if(db.open()) {
      ....
      }
      db = QSqlDatabase();
      
      QSqlDatabase::removeDatabase("DB");
      

      This bug has been present since Qt 4.8 and up.
      Attached file is diff of Qt 5.4.1 version qsql_odbc.cpp

      Attachments

        For Gerrit Dashboard: QTBUG-51334
        # Subject Branch Project Status CR V

        Activity

          People

            iruis HyungDon
            iruis HyungDon
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes