Bug 4792 - realloc is marked as __attribute_malloc__
Summary: realloc is marked as __attribute_malloc__
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-15 22:28 UTC by H.J. Lu
Modified: 2020-06-28 13:20 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2007-07-15 22:28:02 UTC
In <stdlib.h>, there are

/* Re-allocate the previously allocated block
   in PTR, making the new block SIZE bytes long.  */
extern void *realloc (void *__ptr, size_t __size)
     __THROW __attribute_malloc__ __attribute_warn_unused_result__;

However, when a function is marked as mallloc-like, gcc assumes it will
return an address which can alias something else. In case like

#include <stdlib.h>

int *p;
p = malloc (4);
*p = 0;
p = realloc (p, 4);
*p = 1;

will have VOPs that do not prevent re-ordering of the two stores.
Comment 1 Jakub Jelinek 2007-07-20 07:10:59 UTC
Changed in CVS.