From 1d34ddeaaed45c316f0a2b6d3ec5569c92e6c574 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 16 Jun 2003 11:38:49 +0000 Subject: [PATCH] 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 --- ChangeLog | 5 +++++ Source/GSFormat.m | 30 ++++++++++++++++-------------- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9fa02b009..d9db43ba9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-06-16 13:36 Alexander Malmberg + + * 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 * Source/NSAutoreleasePool.m: Documented. diff --git a/Source/GSFormat.m b/Source/GSFormat.m index 23915257e..1d1a4c371 100644 --- a/Source/GSFormat.m +++ b/Source/GSFormat.m @@ -1787,14 +1787,15 @@ NSDictionary *locale) if ((width -= len) <= 0) { outstring (string, len); - break; } - - if (!left) - PAD (' '); - outstring (string, len); - if (left) - PAD (' '); + else + { + if (!left) + PAD (' '); + outstring (string, len); + if (left) + PAD (' '); + } if (string_malloced) NSZoneFree(s->z, string); } @@ -1842,14 +1843,15 @@ NSDictionary *locale) if ((width -= len) < 0) { outstring (string, len); - break; } - - if (!left) - PAD (' '); - outstring (string, len); - if (left) - PAD (' '); + else + { + if (!left) + PAD (' '); + outstring (string, len); + if (left) + PAD (' '); + } if (string_malloced) NSZoneFree(s->z, string); }