Fix bug with empty data object in xml plist

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10592 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2001-07-27 13:30:31 +00:00
parent b680f3e314
commit 71b8835828
3 changed files with 21 additions and 5 deletions

View file

@ -143,11 +143,17 @@ encodeBase64(NSData *source)
int enclen = length / 3;
int remlen = length - 3 * enclen;
int destlen = 4 * ((length - 1) / 3) + 5;
unsigned char *sBuf = (unsigned char*)[source bytes];
unsigned char *dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen);
unsigned char *sBuf;
unsigned char *dBuf;
int sIndex = 0;
int dIndex = 0;
if (length == 0)
{
return @"";
}
sBuf = (unsigned char*)[source bytes];
dBuf = NSZoneMalloc(NSDefaultMallocZone(), destlen);
dBuf[destlen - 1] = '\0';
for (sIndex = 0; sIndex < length - 2; sIndex += 3, dIndex += 4)

View file

@ -571,12 +571,14 @@ failure:
NSZone *z;
extern BOOL GSMacOSXCompatiblePropertyLists();
/* Don't think we want this
if (GSMacOSXCompatiblePropertyLists() == YES)
{
extern NSString *GSXMLPlMake(id obj, NSDictionary *loc, unsigned lev);
return GSXMLPlMake(self, nil, 0);
}
*/
src = [self bytes];
length = [self length];

View file

@ -3817,11 +3817,19 @@ static NSData*
decodeBase64(const char *source)
{
int length = strlen(source);
char *sourceBuffer = objc_malloc(length+1);
NSMutableData *data = [NSMutableData dataWithCapacity:0];
int i, j;
char *sourceBuffer;
NSMutableData *data;
int i;
int j;
unsigned char tmp[4];
if (length == 0)
{
return [NSData data];
}
data = [NSMutableData dataWithCapacity: 0];
sourceBuffer = objc_malloc(length+1);
strcpy(sourceBuffer, source);
j = 0;