Fix decoding of different classes from those encoded by suing name translation.

Was previously only working where both classes existed in the executable.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19440 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-Macdonald 2004-06-02 05:03:28 +00:00
parent f9e9f2feb6
commit f191c5bc11
2 changed files with 36 additions and 6 deletions

View file

@ -1,3 +1,11 @@
2004-06-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUnarchiver.m: Decode class names directly so we can
substitute one class name for another. Letting NSData decode
classes only supported substitution if both the old and new classes
existed in the executable, which is not what was intended.
Thanks to Ludovic Marcotte for spotting this bug.
2004-05-30 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSMime.m: Add support for setting default characterset for

View file

@ -667,33 +667,55 @@ static Class NSDataMallocClass;
{
unsigned cver;
NSString *className;
gsu16 nameLength;
if (xref != GSIArrayCount(clsMap))
{
[NSException raise: NSInternalInconsistencyException
format: @"extra class crossref - %d", xref];
}
(*desImp)(src, desSel, &c, @encode(Class), &cursor, nil);
/*
* A class is encoded as a 16-bit length, a sequence of
* characters providing its name, then a version number.
*/
(*desImp)(src, desSel, &nameLength, @encode(gsu16), &cursor, nil);
if (nameLength == 0)
{
className = nil;
}
else
{
char name[nameLength+1];
[src deserializeBytes: name
length: nameLength
atCursor: &cursor];
name[nameLength] = '\0';
className = [[NSString alloc] initWithUTF8String: name];
}
(*desImp)(src, desSel, &cver, @encode(unsigned), &cursor, nil);
if (c == 0)
if (className == 0)
{
NSLog(@"[%s %s] decoded nil class",
GSNameFromClass([self class]), GSNameFromSelector(_cmd));
className = @"_NSUnarchiverUnknownClass";
}
else
{
className = NSStringFromClass(c);
}
classInfo = [objDict objectForKey: className];
if (classInfo == nil)
{
classInfo = [NSUnarchiverObjectInfo
newWithName: className];
c = NSClassFromString(className);
[classInfo mapToClass: c withName: className];
[objDict setObject: classInfo forKey: className];
RELEASE(classInfo);
}
else
{
c = classInfo->class;
}
RELEASE(className);
classInfo->version = cver;
GSIArrayAddItem(clsMap, (GSIArrayItem)classInfo);
*(Class*)address = mapClassObject(classInfo);