diff options
author | Rodeo <[email protected]> | 2015-04-30 19:18:19 +0000 |
---|---|---|
committer | Rodeo <[email protected]> | 2015-04-30 19:18:19 +0000 |
commit | e6fcf2f40c2628f7780d4841549f5d291024ae9f (patch) | |
tree | d6ae67bbc932baa945be6382c43fe2ae56791b8a /libhb/platform/macosx/config.m | |
parent | 29607855a2ce13dbd843b1d270b4e5bd0adeac35 (diff) |
hb_get_user_config_directory: improvements.
Fix build with older MinGW-w64 toolchains.
Fix potential memory leak and crashes.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@7140 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'libhb/platform/macosx/config.m')
-rw-r--r-- | libhb/platform/macosx/config.m | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libhb/platform/macosx/config.m b/libhb/platform/macosx/config.m index 9fa86aaaf..c30f34c4a 100644 --- a/libhb/platform/macosx/config.m +++ b/libhb/platform/macosx/config.m @@ -1,14 +1,19 @@ #import <Foundation/Foundation.h> -/* #import <Cocoa/Cocoa.h> */ -void osx_get_user_config_directory(char path[512]) +int osx_get_user_config_directory(char path[512]) { - @autoreleasepool { - NSArray *paths = NSSearchPathForDirectoriesInDomains( - NSApplicationSupportDirectory, NSUserDomainMask, YES); - NSString *dir = paths[0]; - strncpy(path, dir.UTF8String, 512); + @autoreleasepool + { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, + NSUserDomainMask, YES); + NSString *dir = paths.firstObject; + if (dir.UTF8String == nil) + { + return -1; + } + + strncpy(path, dir.UTF8String, 511); path[511] = 0; + return 0; } } - |