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

NULL out pointers after freeing them as defensive programming

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • None
    • None
    • Linux (Debian GNU/Linux 10 "buster"

    Description

      In mariadb_lib.c, the mysql_close function contains this code:

      if (mysql->net.extension)
      free(mysql->net.extension);

      mysql->host_info=mysql->user=mysql->passwd=mysql->db=0;

      /* Clear pointers for better safety */
      memset((char*) &mysql->options, 0, sizeof(mysql->options));

      if (mysql->extension)
      free(mysql->extension);

      mysql->net.pvio= 0;
      if (mysql->free_me)
      free(mysql);

      I recommend setting mysql->extension and mysql->net.extension to NULL also as a defensive programming technique. (This is already done for mysql->options.extension in the memset() call).

      This refers to https://jira.mariadb.org/browse/CONC-289 and also fixes the DBD::mysql issue reported at https://github.com/perl5-dbi/DBD-mysql/issues/306

      A patch is attached.

      Regards,

      Dianne.

      Attachments

        Activity

          People

            georg Georg Richter
            dskoll Dianne Skoll
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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