diff --git a/Source/GSSocketStream.m b/Source/GSSocketStream.m index 104d9571f..a72e4ad1d 100644 --- a/Source/GSSocketStream.m +++ b/Source/GSSocketStream.m @@ -1361,6 +1361,7 @@ setNonBlocking(SOCKET fd) struct sockaddr sin; socklen_t size = sizeof(sin); + memset(&sin, '\0', size); if ([key isEqualToString: GSStreamLocalAddressKey]) { if (getsockname(s, (struct sockaddr*)&sin, &size) != -1) diff --git a/Source/NSAffineTransform.m b/Source/NSAffineTransform.m index 322a8edc3..6d716a9d8 100644 --- a/Source/NSAffineTransform.m +++ b/Source/NSAffineTransform.m @@ -596,7 +596,7 @@ static NSAffineTransformStruct identityTransform = { - (id) initWithCoder: (NSCoder*)aCoder { - NSAffineTransformStruct replace; + NSAffineTransformStruct replace = identityTransform; if ([aCoder allowsKeyedCoding]) { diff --git a/Source/NSCoder.m b/Source/NSCoder.m index 5a4ac51a7..b93f9a70f 100644 --- a/Source/NSCoder.m +++ b/Source/NSCoder.m @@ -244,7 +244,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION; - (id) decodeObject { - id o; + id o = nil; [self decodeValueOfObjCType: @encode(id) at: &o]; return AUTORELEASE(o); @@ -253,7 +253,7 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION; - (id) decodePropertyList { id o; - id d; + id d = nil; [self decodeValueOfObjCType: @encode(id) at: &d]; if (d != nil) diff --git a/Source/NSException.m b/Source/NSException.m index c7b56b82a..271fa06c3 100644 --- a/Source/NSException.m +++ b/Source/NSException.m @@ -609,103 +609,106 @@ GSListModules() - (NSArray*) symbols { + if (nil == symbols) + { + NSUInteger count = [addresses count]; + + if (count > 0) + { #if defined(HAVE_BACKTRACE) - if (nil == symbols) - { - char **strs; - void **addr; - NSString **symbolArray; - unsigned count; - int i; + char **strs; + void **addr; + NSString **symbolArray; + NSUInteger i; - count = [addresses count]; - addr = alloca(count * sizeof(void*)); - for (i = 0; i < count; i++) - { - addr[i] = (void*)[[addresses objectAtIndex: i] unsignedIntegerValue]; - } - - strs = backtrace_symbols(addr, count); - symbolArray = alloca(count * sizeof(NSString*)); - for (i = 0; i < count; i++) - { - symbolArray[i] = [NSString stringWithUTF8String: strs[i]]; - } - symbols = [[NSArray alloc] initWithObjects: symbolArray count: count]; - free(strs); - } -#elif defined(USE_BINUTILS) - if (nil == symbols) - { - NSMutableArray *a; - int i; - int n; - - n = [addresses count]; - a = [[NSMutableArray alloc] initWithCapacity: n]; - - for (i = 0; i < n; i++) - { - GSFunctionInfo *aFrame = nil; - void *address; - void *base; - NSString *modulePath; - GSBinaryFileInfo *bfi; - - address = (void*)[[addresses objectAtIndex: i] pointerValue]; - modulePath = GSPrivateBaseAddress(address, &base); - if (modulePath != nil && (bfi = GSLoadModule(modulePath)) != nil) + addr = alloca(count * sizeof(void*)); + for (i = 0; i < count; i++) { - aFrame = [bfi functionForAddress: (void*)(address - base)]; - if (aFrame == nil) - { - /* We know we have the right module but function lookup - * failed ... perhaps we need to use the absolute - * address rather than offest by 'base' in this case. - */ - aFrame = [bfi functionForAddress: address]; - } + addr[i] = (void*)[[addresses objectAtIndex: i] + unsignedIntegerValue]; } - else + + strs = backtrace_symbols(addr, count); + symbolArray = alloca(count * sizeof(NSString*)); + for (i = 0; i < count; i++) { - NSArray *modules; - int j; - int m; + symbolArray[i] = [NSString stringWithUTF8String: strs[i]]; + } + symbols = [[NSArray alloc] initWithObjects: symbolArray count: count]; + free(strs); +#elif defined(USE_BINUTILS) + NSMutableArray *a; + NSUInteger i; - modules = GSListModules(); - m = [modules count]; - for (j = 0; j < m; j++) + a = [[NSMutableArray alloc] initWithCapacity: count]; + + for (i = 0; i < count; i++) + { + GSFunctionInfo *aFrame = nil; + void *address; + void *base; + NSString *modulePath; + GSBinaryFileInfo *bfi; + + address = (void*)[[addresses objectAtIndex: i] pointerValue]; + modulePath = GSPrivateBaseAddress(address, &base); + if (modulePath != nil && (bfi = GSLoadModule(modulePath)) != nil) { - bfi = [modules objectAtIndex: j]; - - if ((id)bfi != (id)[NSNull null]) + aFrame = [bfi functionForAddress: (void*)(address - base)]; + if (aFrame == nil) { + /* We know we have the right module but function lookup + * failed ... perhaps we need to use the absolute + * address rather than offest by 'base' in this case. + */ aFrame = [bfi functionForAddress: address]; - if (aFrame != nil) + } + } + else + { + NSArray *modules; + int j; + int m; + + modules = GSListModules(); + m = [modules count]; + for (j = 0; j < m; j++) + { + bfi = [modules objectAtIndex: j]; + + if ((id)bfi != (id)[NSNull null]) { - break; + aFrame = [bfi functionForAddress: address]; + if (aFrame != nil) + { + break; + } } } } - } - // not found (?!), add an 'unknown' function - if (aFrame == nil) - { - aFrame = [GSFunctionInfo alloc]; - [aFrame initWithModule: nil - address: address - file: nil - function: nil - line: 0]; - [aFrame autorelease]; + // not found (?!), add an 'unknown' function + if (aFrame == nil) + { + aFrame = [GSFunctionInfo alloc]; + [aFrame initWithModule: nil + address: address + file: nil + function: nil + line: 0]; + [aFrame autorelease]; + } + [a addObject: [aFrame description]]; } - [a addObject: [aFrame description]]; - } - symbols = [a copy]; - [a release]; - } + symbols = [a copy]; + [a release]; #endif + } + else + { + symbols = [NSArray new]; + } + } return symbols; } diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m index 50ccf8ddb..dfa96b2ff 100644 --- a/Source/NSProcessInfo.m +++ b/Source/NSProcessInfo.m @@ -758,8 +758,7 @@ static char **_gnu_noobjc_env = NULL; if (_gnu_noobjc_argv == NULL) goto malloc_error; - - ifp=fopen(proc_file_name,"r"); + ifp = fopen(proc_file_name,"r"); //freopen(proc_file_name, "r", ifp); if (ifp == NULL) { @@ -781,17 +780,25 @@ static char **_gnu_noobjc_env = NULL; argument++; length = 0; if (c == EOF) // End of command line - break; + { + _gnu_noobjc_argc = argument; + break; + } } } fclose(ifp); - ifp=fopen(proc_file_name,"r"); + ifp = fopen(proc_file_name,"r"); //freopen(proc_file_name, "r", ifp); if (ifp == NULL) { - for (c = 0; c < _gnu_noobjc_argc; c++) - free(_gnu_noobjc_argv[c]); - free(_gnu_noobjc_argv); + if (0 != _gnu_noobjc_argv) + { + for (c = 0; c < _gnu_noobjc_argc; c++) + { + free(_gnu_noobjc_argv[c]); + } + free(_gnu_noobjc_argv); + } goto proc_fs_error; } argument = 0; diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m index 37ffef023..86e75fd37 100644 --- a/Source/NSRunLoop.m +++ b/Source/NSRunLoop.m @@ -717,12 +717,12 @@ static inline BOOL timerInvalidated(NSTimer *t) GSRunLoopThreadInfo *info = GSRunLoopInfoForThread(nil); NSRunLoop *current = info->loop; - if (current == nil) + if (nil == current) { current = info->loop = [[self alloc] _init]; /* If this is the main thread, set up a housekeeping timer. */ - if ([GSCurrentThread() isMainThread] == YES) + if (nil != current && [GSCurrentThread() isMainThread] == YES) { NSAutoreleasePool *arp = [NSAutoreleasePool new]; GSRunLoopCtxt *context; diff --git a/Source/NSURL.m b/Source/NSURL.m index 2fb223303..3ac7a6e87 100644 --- a/Source/NSURL.m +++ b/Source/NSURL.m @@ -1439,7 +1439,7 @@ static NSUInteger urlAlign; memcpy(tmp, myData->path, l + 1); } } - else if (_baseURL == nil) + else if (nil == _baseURL) { if (myData->path != 0) { @@ -1447,7 +1447,7 @@ static NSUInteger urlAlign; memcpy(tmp, myData->path, l + 1); } } - else if (*myData->path == 0) + else if (0 == myData->path || 0 == *myData->path) { if (baseData->hasNoPath == NO) { diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 296b0ec81..c49d4b265 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -1446,9 +1446,9 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); len = this->cp - ep - 1; *result = [self _newEntity: ep length: len]; - if (entity == *result) + if (&entity == result) { - [entity release]; // Won't be used + [*result release]; // Won't be used } return YES; } diff --git a/Source/common.h b/Source/common.h index 8d81d7d74..8c1a34ff9 100644 --- a/Source/common.h +++ b/Source/common.h @@ -29,6 +29,7 @@ #endif #import "GNUstepBase/GSConfig.h" +#import "GNUstepBase/GSVersionMacros.h" /* Set localisation macro for use within the base library itsself. */ diff --git a/Tools/gdomap.c b/Tools/gdomap.c index e249ef83a..b87e41f5f 100644 --- a/Tools/gdomap.c +++ b/Tools/gdomap.c @@ -2289,6 +2289,7 @@ handle_accept() socklen_t len = sizeof(sa); int desc; + memset(&sa, '\0', len); desc = accept(tcp_desc, (void*)&sa, &len); if (desc >= 0) {