You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/02/13 13:30:39 UTC

[GitHub] [incubator-nuttx] patacongo commented on a change in pull request #265: mm: Fix memory corruption issues in realloc

patacongo commented on a change in pull request #265: mm: Fix memory corruption issues in realloc
URL: https://github.com/apache/incubator-nuttx/pull/265#discussion_r378859408
 
 

 ##########
 File path: mm/mm_heap/mm_realloc.c
 ##########
 @@ -213,6 +215,28 @@ FAR void *mm_realloc(FAR struct mm_heap_s *heap, FAR void *oldmem,
             }
         }
 
+      /* Note that a free node can't be smaller than SIZEOF_MM_FREENODE.
+       * We have to either take the whole node, or leave at least
+       * SIZEOF_MM_FREENODE bytes.
+       * When we can't leave SIZEOF_MM_FREENODE bytes, just take the whole
+       * node. It might end up with returning a larger chunk than the
+       * caller requested. It should be ok.
+       */
+      DEBUGASSERT(prevsize >= takeprev);
 
 Review comment:
   Coding standard requires that all comments be followed by a blank line.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services