mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
Fixup to use the heap if the required workspace buffer is too large.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37684 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1316bf3a0f
commit
2bd91204be
2 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
|||
2014-02-13 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/GSFormat.m: Fix to cope with cases where a format specifies
|
||||
a field width larger than can reasonably fit on the strack ... use
|
||||
the heap.
|
||||
|
||||
2014-02-13 Larry Campbell <lcampbel@akamai.com>
|
||||
|
||||
* Source/NSCalendarDate.m: Fixup millisecond formatting to match OSX
|
||||
|
|
|
@ -833,6 +833,7 @@ NSDictionary *locale)
|
|||
/* Buffer intermediate results. */
|
||||
unichar work_buffer[1000];
|
||||
unichar *workend;
|
||||
int workend_malloced = 0;
|
||||
|
||||
/* State for restartable multibyte character handling functions. */
|
||||
|
||||
|
@ -1144,8 +1145,18 @@ NSDictionary *locale)
|
|||
if ((unsigned)(MAX (prec, width) + 32)
|
||||
> sizeof (work_buffer) / sizeof (unichar))
|
||||
{
|
||||
workend = ((unichar *) alloca ((MAX (prec, width) + 32)
|
||||
* sizeof (unichar)) + (MAX (prec, width) + 32));
|
||||
size_t want = ((MAX (prec, width) + 32)
|
||||
* sizeof (unichar)) + (MAX (prec, width) + 32);
|
||||
|
||||
if (want > 168384)
|
||||
{
|
||||
workend = (unichar *)malloc(want);
|
||||
workend_malloced = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
workend = (unichar *)alloca(want);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process format specifiers. */
|
||||
|
@ -1933,6 +1944,7 @@ NSDictionary *locale)
|
|||
}
|
||||
|
||||
all_done:
|
||||
if (workend_malloced) free(workend);
|
||||
/* Unlock the stream. */
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue