Fixed more leaks found by the Clang Static Analyzer.
authorPeter Hosey <hg@boredzo.org>
Sat Oct 10 12:34:25 2009 -0700 (2009-10-10)
changeset 45101a0499744fd3
parent 4509 714a3c623b46
child 4511 23ffb0a5649f
Fixed more leaks found by the Clang Static Analyzer.
Extras/HardwareGrowler/USBNotifier.c
     1.1 --- a/Extras/HardwareGrowler/USBNotifier.c	Sat Oct 10 12:33:16 2009 -0700
     1.2 +++ b/Extras/HardwareGrowler/USBNotifier.c	Sat Oct 10 12:34:25 2009 -0700
     1.3 @@ -34,18 +34,20 @@
     1.4  			CFStringRef deviceName = CFStringCreateWithCString(kCFAllocatorDefault,
     1.5  															   deviceNameChars,
     1.6  															   kCFStringEncodingASCII);
     1.7 -			if ((CFStringCompare(deviceName, CFSTR("OHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) ||
     1.8 -				(CFStringCompare(deviceName, CFSTR("UHCI Root Hub Simulation"), 0) == kCFCompareEqualTo)) {
     1.9 +			if (deviceName) {
    1.10 +				if ((CFStringCompare(deviceName, CFSTR("OHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) ||
    1.11 +					(CFStringCompare(deviceName, CFSTR("UHCI Root Hub Simulation"), 0) == kCFCompareEqualTo)) {
    1.12 +					CFRelease(deviceName);
    1.13 +					deviceName = CFCopyLocalizedString(CFSTR("USB Bus"), "");
    1.14 +				} else if (CFStringCompare(deviceName, CFSTR("EHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) {
    1.15 +					CFRelease(deviceName);
    1.16 +					deviceName = CFCopyLocalizedString(CFSTR("USB 2.0 Bus"), "");
    1.17 +				}
    1.18 +
    1.19 +				// NSLog(@"USB Device Attached: %@" , deviceName);
    1.20 +				AppController_usbDidConnect(deviceName);
    1.21  				CFRelease(deviceName);
    1.22 -				deviceName = CFCopyLocalizedString(CFSTR("USB Bus"), "");
    1.23 -			} else if (CFStringCompare(deviceName, CFSTR("EHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) {
    1.24 -				CFRelease(deviceName);
    1.25 -				deviceName = CFCopyLocalizedString(CFSTR("USB 2.0 Bus"), "");
    1.26  			}
    1.27 -
    1.28 -			// NSLog(@"USB Device Attached: %@" , deviceName);
    1.29 -			AppController_usbDidConnect(deviceName);
    1.30 -			CFRelease(deviceName);
    1.31  		}
    1.32  
    1.33  		IOObjectRelease(thisObject);
    1.34 @@ -71,14 +73,19 @@
    1.35  		CFStringRef deviceName = CFStringCreateWithCString(kCFAllocatorDefault,
    1.36  														   deviceNameChars,
    1.37  														   kCFStringEncodingASCII);
    1.38 -		if (CFStringCompare(deviceName, CFSTR("OHCI Root Hub Simulation"), 0) == kCFCompareEqualTo)
    1.39 -			deviceName = CFCopyLocalizedString(CFSTR("USB Bus"), "");
    1.40 -		else if (CFStringCompare(deviceName, CFSTR("EHCI Root Hub Simulation"), 0) == kCFCompareEqualTo)
    1.41 -			deviceName = CFCopyLocalizedString(CFSTR("USB 2.0 Bus"), "");
    1.42 +		if (deviceName) {
    1.43 +			if (CFStringCompare(deviceName, CFSTR("OHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) {
    1.44 +				CFRelease(deviceName);
    1.45 +				deviceName = CFCopyLocalizedString(CFSTR("USB Bus"), "");
    1.46 +			} else if (CFStringCompare(deviceName, CFSTR("EHCI Root Hub Simulation"), 0) == kCFCompareEqualTo) {
    1.47 +				CFRelease(deviceName);
    1.48 +				deviceName = CFCopyLocalizedString(CFSTR("USB 2.0 Bus"), "");
    1.49 +			}
    1.50  
    1.51 -		// NSLog(@"USB Device Detached: %@" , deviceName);
    1.52 -		AppController_usbDidDisconnect(deviceName);
    1.53 -		CFRelease(deviceName);
    1.54 +			// NSLog(@"USB Device Detached: %@" , deviceName);
    1.55 +			AppController_usbDidDisconnect(deviceName);
    1.56 +			CFRelease(deviceName);
    1.57 +		}
    1.58  
    1.59  		IOObjectRelease(thisObject);
    1.60  	}