mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix crasher
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/branches/freeze-1_6_0@16096 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5b9b574cc9
commit
e63fcb955d
2 changed files with 62 additions and 82 deletions
|
@ -1,3 +1,8 @@
|
|||
2003-03-01 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSSerializer.m: Fix crash when deserializing a corrupt or
|
||||
truncated archive ... raise exception rather than segfaulting.
|
||||
|
||||
2003-02-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Tools/AGSParser.m: Fix to understand __attribute__() in declaration.
|
||||
|
|
|
@ -410,10 +410,8 @@ static BOOL shouldBeCompact = NO;
|
|||
* Variables to cache class information.
|
||||
*/
|
||||
static BOOL uniquing = NO; /* Make incoming strings unique */
|
||||
static Class IACls = 0; /* Immutable Array */
|
||||
static Class MACls = 0; /* Mutable Array */
|
||||
static Class DCls = 0; /* Data */
|
||||
static Class IDCls = 0; /* Immutable Dictionary */
|
||||
static Class MDCls = 0; /* Mutable Dictionary */
|
||||
static Class USCls = 0; /* Unicode String */
|
||||
static Class CSCls = 0; /* C String */
|
||||
|
@ -433,17 +431,17 @@ static SEL deiSel;
|
|||
static SEL csInitSel;
|
||||
static SEL usInitSel;
|
||||
static SEL dInitSel;
|
||||
static SEL iaInitSel;
|
||||
static SEL maInitSel;
|
||||
static SEL idInitSel;
|
||||
static SEL mdInitSel;
|
||||
static SEL maAddSel;
|
||||
static SEL mdSetSel;
|
||||
static IMP csInitImp;
|
||||
static IMP usInitImp;
|
||||
static IMP dInitImp;
|
||||
static IMP iaInitImp;
|
||||
static IMP maInitImp;
|
||||
static IMP idInitImp;
|
||||
static IMP mdInitImp;
|
||||
static IMP maAddImp;
|
||||
static IMP mdSetImp;
|
||||
|
||||
static void
|
||||
initDeserializerInfo(_NSDeserializerInfo* info, NSData *d, unsigned *c, BOOL m)
|
||||
|
@ -565,42 +563,31 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
|||
case ST_MARRAY:
|
||||
size = (*info->deiImp)(info->data, deiSel, info->cursor);
|
||||
{
|
||||
id objects[size];
|
||||
id a;
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
a = NSAllocateObject(MACls, 0, NSDefaultMallocZone());
|
||||
a = (*maInitImp)(a, maInitSel, size);
|
||||
if (a != nil)
|
||||
{
|
||||
objects[i] = deserializeFromInfo(info);
|
||||
if (objects[i] == nil)
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
while (i > 0)
|
||||
id o = deserializeFromInfo(info);
|
||||
|
||||
if (o == nil)
|
||||
{
|
||||
[objects[--i] release];
|
||||
RELEASE(a);
|
||||
return nil;
|
||||
}
|
||||
#endif
|
||||
objc_free(objects);
|
||||
return nil;
|
||||
(*maAddImp)(a, maAddSel, o);
|
||||
RELEASE(o);
|
||||
}
|
||||
if (code != ST_MARRAY && info->mutable == NO)
|
||||
{
|
||||
[a makeImmutableCopyOnFail: NO];
|
||||
}
|
||||
}
|
||||
if (code == ST_MARRAY || info->mutable)
|
||||
{
|
||||
a = NSAllocateObject(MACls, 0, NSDefaultMallocZone());
|
||||
a = (*maInitImp)(a, maInitSel, objects, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
a = NSAllocateObject(IACls, sizeof(id)*size,
|
||||
NSDefaultMallocZone());
|
||||
a = (*iaInitImp)(a, iaInitSel, objects, size);
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
[objects[i] release];
|
||||
}
|
||||
#endif
|
||||
return a;
|
||||
}
|
||||
|
||||
|
@ -608,56 +595,46 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
|||
case ST_MDICT:
|
||||
size = (*info->deiImp)(info->data, deiSel, info->cursor);
|
||||
{
|
||||
id keys[size];
|
||||
id objects[size];
|
||||
id d;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
d = NSAllocateObject(MDCls, 0, NSDefaultMallocZone());
|
||||
d = (*mdInitImp)(d, mdInitSel, size);
|
||||
if (d != nil)
|
||||
{
|
||||
keys[i] = deserializeFromInfo(info);
|
||||
if (keys[i] == nil)
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
while (i > 0)
|
||||
id k = deserializeFromInfo(info);
|
||||
|
||||
if (k == nil)
|
||||
{
|
||||
[keys[--i] release];
|
||||
[objects[i] release];
|
||||
RELEASE(d);
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
id o = deserializeFromInfo(info);
|
||||
|
||||
if (o == nil)
|
||||
{
|
||||
RELEASE(k);
|
||||
RELEASE(d);
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
(*mdSetImp)(d, mdSetSel, o, k);
|
||||
RELEASE(k);
|
||||
RELEASE(o);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
objects[i] = deserializeFromInfo(info);
|
||||
if (objects[i] == nil)
|
||||
if (code != ST_MDICT && info->mutable == NO)
|
||||
{
|
||||
#if !GS_WITH_GC
|
||||
[keys[i] release];
|
||||
while (i > 0)
|
||||
{
|
||||
[keys[--i] release];
|
||||
[objects[i] release];
|
||||
}
|
||||
#endif
|
||||
return nil;
|
||||
[d makeImmutableCopyOnFail: NO];
|
||||
}
|
||||
}
|
||||
if (code == ST_MDICT || info->mutable)
|
||||
{
|
||||
d = NSAllocateObject(MDCls, 0, NSDefaultMallocZone());
|
||||
d = (*mdInitImp)(d, mdInitSel, objects, keys, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
d = NSAllocateObject(IDCls, 0, NSDefaultMallocZone());
|
||||
d = (*idInitImp)(d, idInitSel, objects, keys, size);
|
||||
}
|
||||
#if !GS_WITH_GC
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
[keys[i] release];
|
||||
[objects[i] release];
|
||||
}
|
||||
#endif
|
||||
return d;
|
||||
}
|
||||
|
||||
|
@ -784,24 +761,22 @@ deserializeFromInfo(_NSDeserializerInfo* info)
|
|||
csInitSel = @selector(initWithCStringNoCopy:length:freeWhenDone:);
|
||||
usInitSel = @selector(initWithCharactersNoCopy:length:freeWhenDone:);
|
||||
dInitSel = @selector(initWithBytesNoCopy:length:);
|
||||
iaInitSel = @selector(initWithObjects:count:);
|
||||
maInitSel = @selector(initWithObjects:count:);
|
||||
idInitSel = @selector(initWithObjects:forKeys:count:);
|
||||
mdInitSel = @selector(initWithObjects:forKeys:count:);
|
||||
IACls = [GSInlineArray class];
|
||||
maInitSel = @selector(initWithCapacity:);
|
||||
mdInitSel = @selector(initWithCapacity:);
|
||||
maAddSel = @selector(addObject:);
|
||||
mdSetSel = @selector(setObject:forKey:);
|
||||
MACls = [GSMutableArray class];
|
||||
DCls = [NSDataMalloc class];
|
||||
IDCls = [GSDictionary class];
|
||||
MDCls = [GSMutableDictionary class];
|
||||
USCls = [GSUnicodeString class];
|
||||
CSCls = [GSCString class];
|
||||
csInitImp = [CSCls instanceMethodForSelector: csInitSel];
|
||||
usInitImp = [USCls instanceMethodForSelector: usInitSel];
|
||||
dInitImp = [DCls instanceMethodForSelector: dInitSel];
|
||||
iaInitImp = [IACls instanceMethodForSelector: iaInitSel];
|
||||
maInitImp = [MACls instanceMethodForSelector: maInitSel];
|
||||
idInitImp = [IDCls instanceMethodForSelector: idInitSel];
|
||||
mdInitImp = [MDCls instanceMethodForSelector: mdInitSel];
|
||||
maAddImp = [MACls instanceMethodForSelector: maAddSel];
|
||||
mdSetImp = [MDCls instanceMethodForSelector: mdSetSel];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue