From 1dd336dba0481ce0ee2d34e731a6a541a4ea5689 Mon Sep 17 00:00:00 2001 From: rfm Date: Fri, 17 May 2013 09:24:10 +0000 Subject: [PATCH] fix error checking file line count in last update git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@36644 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSMessagePortNameServer.m | 20 +++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fb18ef09..93ebdd4bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-05-17 Richard Frith-Macdonald + + * Source/NSMessagePortNameServer.m: fix error in line count check + in last change. + 2013-05-16 Ivan Vučica * Source/GSLocale.m: diff --git a/Source/NSMessagePortNameServer.m b/Source/NSMessagePortNameServer.m index c6857ed27..a3c89523f 100644 --- a/Source/NSMessagePortNameServer.m +++ b/Source/NSMessagePortNameServer.m @@ -157,26 +157,24 @@ static void clean_up_names(void) { NSString *old = [path stringByAppendingPathComponent: file]; NSArray *lines; + NSString *line; + int opid; lines = [[NSString stringWithContentsOfFile: old] componentsSeparatedByString: @"\n"]; - if ([lines count] == 2) + if ([lines count] > 1 + && (opid = [(line = [lines objectAtIndex: 1]) intValue]) > 0) { - NSString *opid = [lines objectAtIndex: 1]; - - if (YES == [opid isEqual: pid]) + if (YES == [line isEqual: pid]) { NSDebugMLLog(@"NSMessagePort", @"Removing old name %@", old); [mgr removeFileAtPath: old handler: nil]; } - else if ([opid intValue] > 0) + else if (NO == [NSProcessInfo _exists: opid]) { - if (NO == [NSProcessInfo _exists: [opid intValue]]) - { - NSDebugMLLog(@"NSMessagePort", - @"Removing old name %@ for process %@", old, pid); - [mgr removeFileAtPath: old handler: nil]; - } + NSDebugMLLog(@"NSMessagePort", + @"Removing old name %@ for process %d", old, opid); + [mgr removeFileAtPath: old handler: nil]; } } else