From 65577d138e516725290571ada000d941faed9754 Mon Sep 17 00:00:00 2001 From: Florian Holzapfel Date: Wed, 20 Mar 2013 14:16:09 +0100 Subject: [PATCH 1/2] fix some memory leaks on iOS --- client/iOS/Controllers/AboutController.m | 2 +- client/iOS/Controllers/AppSettingsController.m | 2 +- client/iOS/Controllers/BookmarkListController.m | 12 ++++++++---- client/iOS/Controllers/HelpController.m | 2 +- client/iOS/Models/Encryptor.m | 2 ++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/client/iOS/Controllers/AboutController.m b/client/iOS/Controllers/AboutController.m index fe4ba3189..a30bb40ba 100644 --- a/client/iOS/Controllers/AboutController.m +++ b/client/iOS/Controllers/AboutController.m @@ -19,7 +19,7 @@ // set title and tab-bar image [self setTitle:NSLocalizedString(@"About", @"About Controller title")]; UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_about" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"About", @"Tabbar item about") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"About", @"Tabbar item about") image:tabBarIcon tag:0] autorelease]]; last_link_clicked = nil; } diff --git a/client/iOS/Controllers/AppSettingsController.m b/client/iOS/Controllers/AppSettingsController.m index 5eaa75807..90b58dbb6 100644 --- a/client/iOS/Controllers/AppSettingsController.m +++ b/client/iOS/Controllers/AppSettingsController.m @@ -27,7 +27,7 @@ if ((self = [super initWithStyle:style])) { UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_settings" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Tabbar item settings") image:tabBarIcon tag:0] autorelease]]; } return self; } diff --git a/client/iOS/Controllers/BookmarkListController.m b/client/iOS/Controllers/BookmarkListController.m index 301bd5f5d..b3f43c732 100644 --- a/client/iOS/Controllers/BookmarkListController.m +++ b/client/iOS/Controllers/BookmarkListController.m @@ -59,7 +59,7 @@ // set title and tabbar controller image [self setTitle:NSLocalizedString(@"Connections", @"'Connections': bookmark controller title")]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:0] autorelease]]; // load images _star_on_img = [[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_accessory_star_on" ofType:@"png"]] retain]; @@ -151,6 +151,9 @@ [_manual_search_result release]; [_manual_bookmarks release]; [_tsxconnect_bookmarks release]; + + [_star_on_img release]; + [_star_off_img release]; [super dealloc]; } @@ -451,7 +454,7 @@ { // resume session RDPSession* session = [_active_sessions objectAtIndex:[indexPath row]]; - UIViewController* ctrl = [[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session]; + UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease]; [ctrl setHidesBottomBarWhenPushed:YES]; [[self navigationController] pushViewController:ctrl animated:YES]; } @@ -466,7 +469,8 @@ if ([[_searchBar text] length] == 0) { // show add bookmark controller - BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:[[ComputerBookmark alloc] initWithBaseDefaultParameters]] autorelease]; + ComputerBookmark *bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease]; + BookmarkEditorController* bookmarkEditorController = [[[BookmarkEditorController alloc] initWithBookmark:bookmark] autorelease]; [bookmarkEditorController setTitle:NSLocalizedString(@"Add Connection", @"Add Connection title")]; [bookmarkEditorController setDelegate:self]; [bookmarkEditorController setHidesBottomBarWhenPushed:YES]; @@ -509,7 +513,7 @@ { // create rdp session RDPSession* session = [[[RDPSession alloc] initWithBookmark:bookmark] autorelease]; - UIViewController* ctrl = [[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session]; + UIViewController* ctrl = [[[RDPSessionViewController alloc] initWithNibName:@"RDPSessionView" bundle:nil session:session] autorelease]; [ctrl setHidesBottomBarWhenPushed:YES]; [[self navigationController] pushViewController:ctrl animated:YES]; [_active_sessions addObject:session]; diff --git a/client/iOS/Controllers/HelpController.m b/client/iOS/Controllers/HelpController.m index 61a05a46c..5ed3bc90b 100644 --- a/client/iOS/Controllers/HelpController.m +++ b/client/iOS/Controllers/HelpController.m @@ -19,7 +19,7 @@ // set title and tab-bar image [self setTitle:NSLocalizedString(@"Help", @"Help Controller title")]; UIImage* tabBarIcon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"tabbar_icon_help" ofType:@"png"]]; - [self setTabBarItem:[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help") image:tabBarIcon tag:0]]; + [self setTabBarItem:[[[UITabBarItem alloc] initWithTitle:NSLocalizedString(@"Help", @"Tabbar item help") image:tabBarIcon tag:0] autorelease]]; } return self; } diff --git a/client/iOS/Models/Encryptor.m b/client/iOS/Models/Encryptor.m index eae578e12..112572218 100644 --- a/client/iOS/Models/Encryptor.m +++ b/client/iOS/Models/Encryptor.m @@ -51,6 +51,7 @@ if (ret) { NSLog(@"%s: CCKeyDerivationPBKDF ret == %d, indicating some sort of failure.", __func__, ret); + free(derived_key); [self autorelease]; return nil; } @@ -64,6 +65,7 @@ if (ret != 1) { NSLog(@"%s: PKCS5_PBKDF2_HMAC_SHA1 ret == %lu, indicating some sort of failure.", __func__, ret); + free(derived_key); [self release]; return nil; } From 1964a2e4f17955dc2f0c102f662806de86a03449 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Thu, 21 Mar 2013 15:13:33 -0700 Subject: [PATCH 2/2] include/winpr/synch.h: add missing extern C decl. --- winpr/include/winpr/synch.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/winpr/include/winpr/synch.h b/winpr/include/winpr/synch.h index e0bf0eed7..dd9bd13b4 100644 --- a/winpr/include/winpr/synch.h +++ b/winpr/include/winpr/synch.h @@ -29,6 +29,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + #ifndef _WIN32 /* Mutex */ @@ -271,5 +275,9 @@ WINPR_API HANDLE CreateWaitObjectEvent(LPSECURITY_ATTRIBUTES lpEventAttributes, WINPR_API int GetEventFileDescriptor(HANDLE hEvent); WINPR_API void* GetEventWaitObject(HANDLE hEvent); +#ifdef __cplusplus +} +#endif + #endif /* WINPR_SYNCH_H */