bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-[NSData initWithContentsOfMappedFile:] crash if MMAP is present


From: Roland Schwingel
Subject: -[NSData initWithContentsOfMappedFile:] crash if MMAP is present
Date: Thu, 06 Mar 2003 14:03:17 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2.1) Gecko/20021130

Hi...

I discovered a crash in NSData...

At line 634: in NSData.m (current CVS head version) you will see
this code:

- (id) initWithContentsOfMappedFile: (NSString *)path
{
#ifdef    HAVE_MMAP
 RELEASE(self);
 self = [NSDataMappedFile allocWithZone: GSObjCZone(self)];
 return [self initWithContentsOfMappedFile: path];
#else
 return [self initWithContentsOfFile: path];
#endif
}

Imagine MMAP is defined. I wonder how this could ever have
worked. It crashes for me (of course) self is released before the
zone is taken from it.

I suggest this change to make it working:
- (id) initWithContentsOfMappedFile: (NSString *)path
{
#if    HAVE_MMAP
 NSZone *myZone = GSObjCZone(self);
 RELEASE(self);
 self = [NSDataMappedFile allocWithZone: myZone];
 return [self initWithContentsOfMappedFile: path];
#else
 return [self initWithContentsOfFile: path];
#endif
}

And now it works for me...

Roland






reply via email to

[Prev in Thread] Current Thread [Next in Thread]