Fix a bug whereby the singleton NSFileHandle instances (stdin, stdout, stderr) are autoreleased and become dangling pointers on exit.

Reported on Stack Overflow:
http://stackoverflow.com/questions/19389749/why-gnustep-nsrunloop-quits-immediately-with-arc



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37245 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
theraven 2013-10-16 13:08:38 +00:00
parent 7e311fc44d
commit 5814ca0029
2 changed files with 19 additions and 3 deletions

View file

@ -964,7 +964,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else
{
self = [self initWithFileDescriptor: 2 closeOnDealloc: NO];
fh_stderr = self;
ASSIGN(fh_stderr, self);
if (self)
{
readOK = NO;
@ -982,7 +982,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else
{
self = [self initWithFileDescriptor: 0 closeOnDealloc: NO];
fh_stdin = self;
ASSIGN(fh_stdin, self);
if (self)
{
writeOK = NO;
@ -1000,7 +1000,7 @@ NSString * const GSSOCKSRecvAddr = @"GSSOCKSRecvAddr";
else
{
self = [self initWithFileDescriptor: 1 closeOnDealloc: NO];
fh_stdout = self;
ASSIGN(fh_stdout, self);
if (self)
{
readOK = NO;

View file

@ -0,0 +1,16 @@
#import <Foundation/Foundation.h>
id a,b,c;
int main(void)
{
NSAutoreleasePool *p = [NSAutoreleasePool new];
NSZombieEnabled = YES;
a = [NSFileHandle fileHandleWithStandardInput];
b = [NSFileHandle fileHandleWithStandardOutput];
c = [NSFileHandle fileHandleWithStandardError];
[p drain];
assert(0 != [a description]);
assert(0 != [b description]);
assert(0 != [c description]);
}