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

Return value of realloc must not be assigned to provided pointer.

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Done
    • 1.1.0, 1.2.0, 1.3.0, 1.4.0
    • 2.1.0
    • Core
    • None
    • 2016-12

    Description

      If realloc fails it returns NULL. Thus, in a situation like

      void* p = ...;
      ...;
      p = realloc(p, ...);
      

      if realloc fails, the previously allocated memory will leak. Realloc must be used like:

      void* p = ...;
      ...;
      void* tmp = realloc(p, ...);
       
      if (tmp) {
          p = tmp;
      } else {
          ...
      }
      

      Attachments

        Issue Links

          Activity

            People

              johan.wikman Johan Wikman
              johan.wikman Johan Wikman
              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.