diff --git a/ChangeLog b/ChangeLog index a32f9d828..8f62ec021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2011-02-11 Richard Frith-Macdonald + * 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 + * Source/NSKeyValueObserving.m: Recommit Reviewed and tested. * Source/NAutoreleasePool.m: Make +initialize do nothing so that it diff --git a/Source/GSPrivate.h b/Source/GSPrivate.h index 3110e95a2..f5aaadd57 100644 --- a/Source/GSPrivate.h +++ b/Source/GSPrivate.h @@ -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]; \