Do not call unum_format* more than once.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34634 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
stefanbidi 2012-01-26 01:40:12 +00:00
parent c4f47d50c7
commit 1c6a149a32
2 changed files with 7 additions and 8 deletions

View file

@ -1,3 +1,7 @@
2012-01-25 Stefan Bidigaray <stefanbidi@gmail.com>
* Source/NSNumberFormatter.m: Call unum_format* only once.
2012-01-25 Richard Frith-Macdonald <rfm@gnu.org> 2012-01-25 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSSocketStream.m: fix possible nul pointer dereference. * Source/GSSocketStream.m: fix possible nul pointer dereference.

View file

@ -1055,20 +1055,15 @@ static NSUInteger _defaultBehavior = NSNumberFormatterBehavior10_4;
#define STRING_FROM_NUMBER(function, number) do \ #define STRING_FROM_NUMBER(function, number) do \
{ \ { \
UChar *outStr = buffer; \
UErrorCode err = U_ZERO_ERROR; \ UErrorCode err = U_ZERO_ERROR; \
int32_t len; \ int32_t len; \
NSString *result; \ NSString *result; \
\ \
len = function (internal->_formatter, number, outStr, \ len = function (internal->_formatter, number, buffer, \
BUFFER_SIZE, NULL, &err); \ BUFFER_SIZE, NULL, &err); \
if (len > BUFFER_SIZE) \ if (len > BUFFER_SIZE) \
outStr = NSZoneMalloc ([self zone], len * sizeof(UChar));\ len = BUFFER_SIZE; \
err = U_ZERO_ERROR; \ result = [NSString stringWithCharacters: buffer length: len]; \
function (internal->_formatter, number, outStr, BUFFER_SIZE, NULL, &err); \
result = [NSString stringWithCharacters: outStr length: len]; \
if (len > BUFFER_SIZE) \
NSZoneFree ([self zone], outStr); \
return result; \ return result; \
} while (0) } while (0)