mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 03:15:21 +08:00
Protect NSHomeDirectory() call by an NSAutoreleasePool.
That may be necessary if preferences are accessed before fl_open_display() was called.
This commit is contained in:
+3
-1
@@ -4441,12 +4441,14 @@ char *Fl_Darwin_System_Driver::preference_rootnode(Fl_Preferences *prefs, Fl_Pre
|
|||||||
case Fl_Preferences::USER:
|
case Fl_Preferences::USER:
|
||||||
{ // Find the home directory, but return NULL if components were not found.
|
{ // Find the home directory, but return NULL if components were not found.
|
||||||
// If we ever port this to iOS: NSHomeDirectory returns tha location of the app!
|
// If we ever port this to iOS: NSHomeDirectory returns tha location of the app!
|
||||||
const char *e = getenv("HOME");
|
const char *e = ::getenv("HOME");
|
||||||
// if $HOME does not exist, try NSHomeDirectory, the Mac way.
|
// if $HOME does not exist, try NSHomeDirectory, the Mac way.
|
||||||
if ( (e==0L) || (e[0]==0) || (::access(e, F_OK)==-1) ) {
|
if ( (e==0L) || (e[0]==0) || (::access(e, F_OK)==-1) ) {
|
||||||
|
NSAutoreleasePool *localPool = [[NSAutoreleasePool alloc] init];
|
||||||
NSString *nsHome = NSHomeDirectory();
|
NSString *nsHome = NSHomeDirectory();
|
||||||
if (nsHome)
|
if (nsHome)
|
||||||
e = [nsHome UTF8String];
|
e = [nsHome UTF8String];
|
||||||
|
[localPool release];
|
||||||
}
|
}
|
||||||
// if NSHomeDirectory does not work, try getpwuid(), the Unix way.
|
// if NSHomeDirectory does not work, try getpwuid(), the Unix way.
|
||||||
if ( (e==0L) || (e[0]==0) || (::access(e, F_OK)==-1) ) {
|
if ( (e==0L) || (e[0]==0) || (::access(e, F_OK)==-1) ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user