Don't leak memory when handling %s, %S, %@ with strings longer than 8191 characters.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16931 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2003-06-16 11:38:49 +00:00
parent 2cc6bd5f1a
commit 1d34ddeaae
2 changed files with 21 additions and 14 deletions

View file

@ -1,3 +1,8 @@
2003-06-16 13:36 Alexander Malmberg <alexander@malmberg.org>
* Source/GSFormat.m (GSFormat()): Free malloc memory in all cases
after handling %s, %S, %@ with strings longer than 8192 characters.
2003-06-15 Richard Frith-Macdonald <rfm@gnu.org> 2003-06-15 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSAutoreleasePool.m: Documented. * Source/NSAutoreleasePool.m: Documented.

View file

@ -1787,14 +1787,15 @@ NSDictionary *locale)
if ((width -= len) <= 0) if ((width -= len) <= 0)
{ {
outstring (string, len); outstring (string, len);
break;
} }
else
if (!left) {
PAD (' '); if (!left)
outstring (string, len); PAD (' ');
if (left) outstring (string, len);
PAD (' '); if (left)
PAD (' ');
}
if (string_malloced) if (string_malloced)
NSZoneFree(s->z, string); NSZoneFree(s->z, string);
} }
@ -1842,14 +1843,15 @@ NSDictionary *locale)
if ((width -= len) < 0) if ((width -= len) < 0)
{ {
outstring (string, len); outstring (string, len);
break;
} }
else
if (!left) {
PAD (' '); if (!left)
outstring (string, len); PAD (' ');
if (left) outstring (string, len);
PAD (' '); if (left)
PAD (' ');
}
if (string_malloced) if (string_malloced)
NSZoneFree(s->z, string); NSZoneFree(s->z, string);
} }