various minor bugfixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30470 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2010-05-29 06:42:38 +00:00
parent 8633b7d611
commit 6388ec9d4f
7 changed files with 25 additions and 19 deletions

View file

@ -3822,6 +3822,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
unsigned char *dst;
unsigned char buf[4];
NSUInteger pos = 0;
int pad = 0;
if (source == nil)
{
@ -3870,6 +3871,7 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
else if (c == '=')
{
c = -1;
pad++;
}
else if (c == '-')
{
@ -3895,19 +3897,15 @@ appendString(NSMutableData *m, NSUInteger offset, NSUInteger fold,
if (pos > 0)
{
NSUInteger i;
unsigned char tail[3];
for (i = pos; i < 4; i++)
{
buf[i] = '\0';
}
pos--;
if (pos > 0)
{
unsigned char tail[3];
decodebase64(tail, buf);
memcpy(dst, tail, pos);
dst += pos;
}
decodebase64(tail, buf);
memcpy(dst, tail, 3 - pad);
dst += 3 - pad;
}
return AUTORELEASE([[NSData allocWithZone: NSDefaultMallocZone()]
initWithBytesNoCopy: result length: dst - result]);