Fix major mamory corruption problem.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32085 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2011-02-11 18:53:24 +00:00
parent 6f4f708a6f
commit 992b57e83b
2 changed files with 16 additions and 9 deletions

View file

@ -1,5 +1,12 @@
2011-02-11 Richard Frith-Macdonald <rfm@gnu.org>
* libs/base/trunk/Source/GSPrivate.h: Fixed the new GS_BEGINITEMBUF()
code ... was causing hard-to-track-down memory corruption which
unfortunately didn't show up in the testsuite (or I'd not have
re-comitted this code in the first place).
2_011-02-11 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSKeyValueObserving.m: Recommit
Reviewed and tested.
* Source/NAutoreleasePool.m: Make +initialize do nothing so that it

View file

@ -96,17 +96,17 @@ typedef struct objc_category* Category;
#if __GNUC__ > 3
__attribute__((unused)) static void GSFreeTempBuffer(void **b)
{
if (NULL != *b) free(*b);
if (NULL != *b) free(*b);
}
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[GS_MAX_OBJECTS_FROM_STACK];\
T *P = _ibuf;\
__attribute__((cleanup(GSFreeTempBuffer))) void *_base = 0;\
if (S > GS_MAX_OBJECTS_FROM_STACK)\
{\
_base = malloc(S);\
P = _base;\
}
T _ibuf[GS_MAX_OBJECTS_FROM_STACK];\
T *P = _ibuf;\
__attribute__((cleanup(GSFreeTempBuffer))) void *_base = 0;\
if (S > GS_MAX_OBJECTS_FROM_STACK)\
{\
_base = malloc((S) * sizeof(T));\
P = _base;\
}
#else
# define GS_BEGINITEMBUF(P, S, T) { \
T _ibuf[(S) <= GS_MAX_OBJECTS_FROM_STACK ? (S) : 0]; \