Bug 1225923 - part 2 - fix AppendElement(nsDependentString(...)) call in HTMLInputElement.cpp; r=baku

I think the intent of this call is to not copy the filename data passed
in, but to simply convert it to a friendlier nsString container for
processing.  We don't have to worry about the nsTArray<nsString>
overload of MozSetFileNameArray holding references to the strings
outside the call, as the elements of the array are copied into new
strings as appropriate.
This commit is contained in:
Nathan Froyd 2015-11-18 10:36:40 -05:00
parent 84e3d19a36
commit 3a7ec13963

View File

@ -2154,10 +2154,13 @@ HTMLInputElement::MozSetFileNameArray(const char16_t** aFileNames, uint32_t aLen
}
Sequence<nsString> list;
nsString* names = list.AppendElements(aLength, fallible);
if (!names) {
return NS_ERROR_OUT_OF_MEMORY;
}
for (uint32_t i = 0; i < aLength; ++i) {
if (!list.AppendElement(nsDependentString(aFileNames[i]), fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
const char16_t* filename = aFileNames[i];
names[i].Rebind(filename, nsCharTraits<char16_t>::length(filename));
}
ErrorResult rv;