[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
-[NSFileManager fileSystemRepresentationWithPath:] not error safe - will
From: |
Roland Schwingel |
Subject: |
-[NSFileManager fileSystemRepresentationWithPath:] not error safe - will crash on argument=nil |
Date: |
Mon, 16 Sep 2002 11:53:42 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826 |
Hi...
While migrating sources I found that fileSystemRepresentationWithPath:
can not
correctly handle arguments equal to nil so it will crash on win. (I am
using base-1.5.0)
This method is quite frequently used in NSFileManager on many locations.
- (const char*) fileSystemRepresentationWithPath: (NSString*)path
{
#ifdef __MINGW__
/*
* If path is in Unix format, transmogrify it so Windows functions
* can handle it
*/
NSString *newpath;
const char *c_path;
int l;
path = [path stringByStandardizingPath];
newpath = path;
c_path = [path cString];
l = strlen(c_path);
if (c_path == 0)
{
return 0;
}
...
If you supply nil for path it will crash in strlen() which is quite ugly.
I suggest to move
l = strlen(c_path);
after the following if (c_path == 0) statement. So the method will
correctly exit in this case.
(and bringing back OS4.2 behaviour).
What do you think? Is this change acceptable?
Roland
- -[NSFileManager fileSystemRepresentationWithPath:] not error safe - will crash on argument=nil,
Roland Schwingel <=