зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1453134 - part 3 - be smarter about input stream semantics in DataTransfer; r=baku
We could have used the new NS_NewCStringInputStream overload here, but it seemed nicer to directly transfer ownership into the newly-created stream. If we're going to be more efficient here, we might as well go as far as when can without making the code too ugly.
This commit is contained in:
Родитель
62f2c5af64
Коммит
798efd6d66
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "mozilla/BasicEvents.h"
|
||||
#include "mozilla/CheckedInt.h"
|
||||
|
||||
#include "DataTransfer.h"
|
||||
|
||||
|
@ -1470,11 +1471,14 @@ DataTransfer::FillInExternalCustomTypes(nsIVariant* aData, uint32_t aIndex,
|
|||
return;
|
||||
}
|
||||
|
||||
nsAutoCString str;
|
||||
str.Adopt(chrs, len);
|
||||
CheckedInt<int32_t> checkedLen(len);
|
||||
if (!checkedLen.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInputStream> stringStream;
|
||||
NS_NewCStringInputStream(getter_AddRefs(stringStream), str);
|
||||
NS_NewByteInputStream(getter_AddRefs(stringStream), chrs, checkedLen.value(),
|
||||
NS_ASSIGNMENT_ADOPT);
|
||||
|
||||
nsCOMPtr<nsIObjectInputStream> stream =
|
||||
NS_NewObjectInputStream(stringStream);
|
||||
|
|
Загрузка…
Ссылка в новой задаче