Bug 1161240 - Make sure that NS_CloneInputStream correctly deals with null input; r=froydnj

This commit is contained in:
Ehsan Akhgari 2015-05-04 16:52:23 -04:00
Родитель cd411ff6db
Коммит d2b480a8db
2 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -853,6 +853,10 @@ nsresult
NS_CloneInputStream(nsIInputStream* aSource, nsIInputStream** aCloneOut,
nsIInputStream** aReplacementOut)
{
if (NS_WARN_IF(!aSource)) {
return NS_ERROR_FAILURE;
}
// Attempt to perform the clone directly on the source stream
nsCOMPtr<nsICloneableInputStream> cloneable = do_QueryInterface(aSource);
if (cloneable && cloneable->GetCloneable()) {

Просмотреть файл

@ -12,6 +12,14 @@
#include "nsStreamUtils.h"
#include "nsStringStream.h"
TEST(CloneInputStream, InvalidInput)
{
nsCOMPtr<nsIInputStream> clone;
nsresult rv = NS_CloneInputStream(nullptr, getter_AddRefs(clone));
ASSERT_TRUE(NS_FAILED(rv));
ASSERT_FALSE(clone);
}
TEST(CloneInputStream, CloneableInput)
{
nsTArray<char> inputData;