Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-9465

The constructor StringBuffer(const char *str, size_t length, const CHARSET_INFO *cs) looks suspicious

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.1(EOL)
    • 10.1.39
    • OTHER
    • None

    Description

      The second StringBuffer constructor looks suspicious:

        StringBuffer(const char *str, size_t length, const CHARSET_INFO *cs)
          : String(buff, buff_sz, cs)
        {
          set(str, length, cs);
        }

      It calls this String() constructor:

        String(char *str,uint32 len, CHARSET_INFO *cs)
        { 
          Ptr=(char*) str; Alloced_length=str_length=len; extra_alloc= 0;
          alloced= thread_specific= 0;
          str_charset=cs;
        }

      and then calls this set():

        inline void set(const char *str,uint32 arg_length, CHARSET_INFO *cs)
        {
          free();
          Ptr=(char*) str; str_length=arg_length;
          str_charset=cs;
        }

      So "ptr" does not point to StringBuffer::buff any more. This call sequence seems to have a very little sense. Perhaps it should be copy() instead of set().

      Attachments

        Activity

          People

            bar Alexander Barkov
            bar Alexander Barkov
            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.