Bug 381315 - nsINIParser crashes when linked against a static CRT (opera profile migrator), r=dougt

This commit is contained in:
2007-05-25 08:05:11 -07:00
parent 9a39fa1625
commit 0c17ee2f62

View File

@@ -70,11 +70,27 @@ nsINIParser::Init(nsILocalFile* aFile)
{
nsresult rv;
/* open the file */
/* open the file. Don't use OpenANSIFileDesc, because you mustn't
pass FILE* across shared library boundaries, which may be using
different CRTs */
AutoFILE fd;
rv = aFile->OpenANSIFileDesc("r" BINARY_MODE, &fd);
if (NS_FAILED(rv))
return rv;
#ifdef XP_WIN
nsAutoString path;
rv = aFile->GetPath(path);
NS_ENSURE_SUCCESS(rv, rv);
fd = _wfopen(path.get(), L"rb");
#else
nsCAutoString path;
rv = aFile->GetNativePath(path);
NS_ENSURE_SUCCESS(rv, rv);
fd = fopen(path.get(), "r" BINARY_MODE);
#endif
if (!fd)
return NS_ERROR_FAILURE;
return InitFromFILE(fd);
}