From cc2156d4b95114ef8f31d1dccdbe80a171800502 Mon Sep 17 00:00:00 2001 From: Richard Frith-MacDonald Date: Tue, 4 Apr 2000 18:36:46 +0000 Subject: [PATCH] Fix appending nul string git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6414 72102866-910b-0410-8b05-ffd578937521 --- Source/NSString.m | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Source/NSString.m b/Source/NSString.m index 1b1d694f4..4339d0d02 100644 --- a/Source/NSString.m +++ b/Source/NSString.m @@ -1983,23 +1983,26 @@ handle_printf_atsign (FILE *stream, { length--; } - aLength = length - 1; - while (aLength > 1) + if (length > 0) { - if (pathSepMember(buf[aLength]) == YES) + aLength = length - 1; + while (aLength > 1) { - if (pathSepMember(buf[aLength-1]) == YES) + if (pathSepMember(buf[aLength]) == YES) { - unsigned pos; - - for (pos = aLength+1; pos < length; pos++) + if (pathSepMember(buf[aLength-1]) == YES) { - buf[pos-1] = buf[pos]; + unsigned pos; + + for (pos = aLength+1; pos < length; pos++) + { + buf[pos-1] = buf[pos]; + } + length--; } - length--; } + aLength--; } - aLength--; } return [NSString stringWithCharacters: buf length: length]; }