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:
Stefan Bidigaray 2012-01-26 01:40:12 +00:00
parent 1abad06f3a
commit 598c5de32a
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>
* 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 \
{ \
UChar *outStr = buffer; \
UErrorCode err = U_ZERO_ERROR; \
int32_t len; \
NSString *result; \
\
len = function (internal->_formatter, number, outStr, \
len = function (internal->_formatter, number, buffer, \
BUFFER_SIZE, NULL, &err); \
if (len > BUFFER_SIZE) \
outStr = NSZoneMalloc ([self zone], len * sizeof(UChar));\
err = U_ZERO_ERROR; \
function (internal->_formatter, number, outStr, BUFFER_SIZE, NULL, &err); \
result = [NSString stringWithCharacters: outStr length: len]; \
if (len > BUFFER_SIZE) \
NSZoneFree ([self zone], outStr); \
len = BUFFER_SIZE; \
result = [NSString stringWithCharacters: buffer length: len]; \
return result; \
} while (0)