mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +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
ffe960f77e
commit
017bda675b
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>
|
2014-02-13 Larry Campbell <lcampbel@akamai.com>
|
||||||
|
|
||||||
* Source/NSCalendarDate.m: Fixup millisecond formatting to match OSX
|
* Source/NSCalendarDate.m: Fixup millisecond formatting to match OSX
|
||||||
|
|
|
@ -833,6 +833,7 @@ NSDictionary *locale)
|
||||||
/* Buffer intermediate results. */
|
/* Buffer intermediate results. */
|
||||||
unichar work_buffer[1000];
|
unichar work_buffer[1000];
|
||||||
unichar *workend;
|
unichar *workend;
|
||||||
|
int workend_malloced = 0;
|
||||||
|
|
||||||
/* State for restartable multibyte character handling functions. */
|
/* State for restartable multibyte character handling functions. */
|
||||||
|
|
||||||
|
@ -1144,8 +1145,18 @@ NSDictionary *locale)
|
||||||
if ((unsigned)(MAX (prec, width) + 32)
|
if ((unsigned)(MAX (prec, width) + 32)
|
||||||
> sizeof (work_buffer) / sizeof (unichar))
|
> sizeof (work_buffer) / sizeof (unichar))
|
||||||
{
|
{
|
||||||
workend = ((unichar *) alloca ((MAX (prec, width) + 32)
|
size_t want = ((MAX (prec, width) + 32)
|
||||||
* sizeof (unichar)) + (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. */
|
/* Process format specifiers. */
|
||||||
|
@ -1933,6 +1944,7 @@ NSDictionary *locale)
|
||||||
}
|
}
|
||||||
|
|
||||||
all_done:
|
all_done:
|
||||||
|
if (workend_malloced) free(workend);
|
||||||
/* Unlock the stream. */
|
/* Unlock the stream. */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue