Uploaded image for project: 'MariaDB MaxScale'
  1. MariaDB MaxScale
  2. MXS-840

Return value of gwbuf_make_contiguous should be checked.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Incomplete
    • None
    • N/A
    • N/A
    • None

    Description

      A common pattern is

      void function(GWBUF *queue)
      {
          ...
          queue = gwbuf_make_contiguous(queue);
      }
      

      However, gwbuf_make_contiguous behaves like realloc, that is, the memory allocation can fail and the function can return NULL, in which case the original buffer will leak and the code will steam ahead towards a SIGSEGV.

      Correct way would be

      void function(GWBUF *queue)
      {
          ...
          GWBUF *tmp = gwbuf_make_contiguous(queue);
          if (tmp)
          {
              queue = tmp;
          }
          else
          {
              // Handle problem.
          }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            johan.wikman Johan Wikman
            Votes:
            0 Vote for this issue
            Watchers:
            1 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.