Bug 666224 - Fix off-by-one error when checking nsCommandLine::GetArgument aIndex argument. r=bsmedberg

This commit is contained in:
arno renevier 2011-06-25 11:49:03 +02:00
parent 205bc10c08
commit cfdb7c5679
3 changed files with 8 additions and 1 deletions

View File

@ -132,7 +132,7 @@ NS_IMETHODIMP
nsCommandLine::GetArgument(PRInt32 aIndex, nsAString& aResult)
{
NS_ENSURE_ARG_MIN(aIndex, 0);
NS_ENSURE_ARG_MAX(PRUint32(aIndex), mArgs.Length());
NS_ENSURE_ARG_MAX(aIndex, PRInt32(mArgs.Length() - 1));
aResult = mArgs[aIndex];
return NS_OK;

View File

@ -0,0 +1,6 @@
function run_test() {
var cmdLine=Components.classes["@mozilla.org/toolkit/command-line;1"].createInstance(Components.interfaces.nsICommandLine);
try {
cmdLine.getArgument(cmdLine.length);
} catch(e) {}
}

View File

@ -3,3 +3,4 @@ head =
tail =
[test_classinfo.js]
[test_bug666224.js]