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

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

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Minor
    • Resolution: Done
    • Affects Version/s: 1.1.0, 1.2.0, 1.3.0, 1.4.0
    • Fix Version/s: 2.1.0
    • Component/s: Core
    • Labels:
      None
    • Sprint:
      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

              • Assignee:
                johan.wikman Johan Wikman
                Reporter:
                johan.wikman Johan Wikman
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: