зеркало из https://github.com/mozilla/gecko-dev.git
More fixing for startup crashes and other badness (bugs 25366 and 24312). Fix off by one buffer write. r=sdagley
This commit is contained in:
Родитель
2508c667ce
Коммит
27e45a31de
|
@ -558,7 +558,6 @@ nsLocalFile::ResolveAndStat(PRBool resolveTerminal)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsLocalFile::Clone(nsIFile **file)
|
nsLocalFile::Clone(nsIFile **file)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
|
||||||
NS_ENSURE_ARG(file);
|
NS_ENSURE_ARG(file);
|
||||||
*file = nsnull;
|
*file = nsnull;
|
||||||
|
|
||||||
|
@ -572,6 +571,8 @@ nsLocalFile::Clone(nsIFile **file)
|
||||||
if (localFileMac == NULL)
|
if (localFileMac == NULL)
|
||||||
return NS_ERROR_NO_INTERFACE;
|
return NS_ERROR_NO_INTERFACE;
|
||||||
|
|
||||||
|
nsresult rv = NS_OK;
|
||||||
|
|
||||||
// Now we figure out how we were initialized in order to determine how to
|
// Now we figure out how we were initialized in order to determine how to
|
||||||
// initialize the clone
|
// initialize the clone
|
||||||
nsLocalFileMacInitType initializedAs;
|
nsLocalFileMacInitType initializedAs;
|
||||||
|
@ -582,7 +583,7 @@ nsLocalFile::Clone(nsIFile **file)
|
||||||
// The simple case
|
// The simple case
|
||||||
char *path;
|
char *path;
|
||||||
GetPath(&path);
|
GetPath(&path);
|
||||||
localFile->InitWithPath(path);
|
rv = localFile->InitWithPath(path);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case eInitWithFSSpec:
|
case eInitWithFSSpec:
|
||||||
|
@ -593,12 +594,12 @@ nsLocalFile::Clone(nsIFile **file)
|
||||||
// Now set any appended path info
|
// Now set any appended path info
|
||||||
char *appendedPath;
|
char *appendedPath;
|
||||||
GetAppendedPath(&appendedPath);
|
GetAppendedPath(&appendedPath);
|
||||||
localFileMac->SetAppendedPath(appendedPath);
|
rv = localFileMac->SetAppendedPath(appendedPath);
|
||||||
|
nsAllocator::Free(appendedPath);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// !!!!! Danger Will Robinson !!!!!
|
NS_NOTREACHED("we really shouldn't get here");
|
||||||
// we really shouldn't get here
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,12 +873,13 @@ nsLocalFile::GetLeafName(char * *aLeafName)
|
||||||
// We don't have an appended path so grab the leaf name from the FSSpec
|
// We don't have an appended path so grab the leaf name from the FSSpec
|
||||||
// Convert the Pascal string to a C string
|
// Convert the Pascal string to a C string
|
||||||
unsigned long len = mSpec.name[0];
|
unsigned long len = mSpec.name[0];
|
||||||
char * tempStr = (char *)PR_MALLOC(len);
|
char * tempStr = (char *)PR_MALLOC(len + 1);
|
||||||
if (tempStr)
|
if (tempStr)
|
||||||
{
|
{
|
||||||
::BlockMoveData(&mSpec.name[1], tempStr, len);
|
::BlockMoveData(&mSpec.name[1], tempStr, len);
|
||||||
tempStr[len] = NULL;
|
tempStr[len] = '\0';
|
||||||
*aLeafName = (char*) nsAllocator::Clone(tempStr, strlen(tempStr)+1);
|
*aLeafName = (char*) nsAllocator::Clone(tempStr, len + 1);
|
||||||
|
PR_DELETE(tempStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче