Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-294

Access violation on mysql_close with a connection plugin.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 3.0.2
    • 3.0.4
    • None
    • None

    Description

      int
      mthd_my_send_cmd(MYSQL *mysql,enum enum_server_command command, const char *arg,
      	       size_t length, my_bool skipp_check, void *opt_arg)
      {
      ......
        if (IS_CONNHDLR_ACTIVE(mysql)) // <- Wrongly thinks that mysql->extension->conn_hdlr has something after free(p) at line 1920
        {
          result= mysql->extension->conn_hdlr->plugin->set_connection(mysql, command, arg, length, skipp_check, opt_arg); // <- Exception!!!
          if (result== -1)
            return(result);
        }
      ....
      

      The problem is because mysql->extension->conn_hdlr is kept with a value after "free(p);" at line 1920.

          if (mysql->extension && mysql->extension->conn_hdlr)
          {
            MA_CONNECTION_HANDLER *p= mysql->extension->conn_hdlr;
            p->plugin->close(mysql);
            free(p); // <- HERE
          }
       
          if (mysql->methods)
            mysql->methods->db_close(mysql); // <- Problem!
      

      Should be

          if (mysql->extension && mysql->extension->conn_hdlr)
          {
            MA_CONNECTION_HANDLER *p= mysql->extension->conn_hdlr;
            p->plugin->close(mysql);
            free(p);
            mysql->extension->conn_hdlr = NULL; // <- Solution
          }
       
          if (mysql->methods)
            mysql->methods->db_close(mysql);
      

      Attachments

        Activity

          People

            georg Georg Richter
            andywolk Andrey Volk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.