| Index: tools/ipc_fuzzer/fuzzer/fuzzer.cc
|
| diff --git a/tools/ipc_fuzzer/fuzzer/fuzzer.cc b/tools/ipc_fuzzer/fuzzer/fuzzer.cc
|
| index a913dc23eb78bd86a18506e2345ed007ad8e2310..159ee81f3d7e0f6e042614abc0ae20f552ecf1e0 100644
|
| --- a/tools/ipc_fuzzer/fuzzer/fuzzer.cc
|
| +++ b/tools/ipc_fuzzer/fuzzer/fuzzer.cc
|
| @@ -10,6 +10,7 @@
|
| #include <vector>
|
|
|
| #include "base/macros.h"
|
| +#include "base/memory/ptr_util.h"
|
| #include "base/memory/shared_memory_handle.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/values.h"
|
| @@ -510,28 +511,28 @@ struct FuzzTraits<base::ListValue> {
|
| bool tmp;
|
| p->GetBoolean(index, &tmp);
|
| fuzzer->FuzzBool(&tmp);
|
| - p->Set(index, new base::Value(tmp));
|
| + p->Set(index, base::MakeUnique<base::Value>(tmp));
|
| break;
|
| }
|
| case base::Value::Type::INTEGER: {
|
| int tmp;
|
| p->GetInteger(index, &tmp);
|
| fuzzer->FuzzInt(&tmp);
|
| - p->Set(index, new base::Value(tmp));
|
| + p->Set(index, base::MakeUnique<base::Value>(tmp));
|
| break;
|
| }
|
| case base::Value::Type::DOUBLE: {
|
| double tmp;
|
| p->GetDouble(index, &tmp);
|
| fuzzer->FuzzDouble(&tmp);
|
| - p->Set(index, new base::Value(tmp));
|
| + p->Set(index, base::MakeUnique<base::Value>(tmp));
|
| break;
|
| }
|
| case base::Value::Type::STRING: {
|
| std::string tmp;
|
| p->GetString(index, &tmp);
|
| fuzzer->FuzzString(&tmp);
|
| - p->Set(index, new base::Value(tmp));
|
| + p->Set(index, base::MakeUnique<base::Value>(tmp));
|
| break;
|
| }
|
| case base::Value::Type::BINARY: {
|
| @@ -542,17 +543,25 @@ struct FuzzTraits<base::ListValue> {
|
| break;
|
| }
|
| case base::Value::Type::DICTIONARY: {
|
| - base::DictionaryValue* tmp = new base::DictionaryValue();
|
| - p->GetDictionary(index, &tmp);
|
| - FuzzParam(tmp, fuzzer);
|
| - p->Set(index, tmp);
|
| + base::DictionaryValue* dict_weak = nullptr;
|
| + if (p->GetDictionary(index, &dict_weak)) {
|
| + FuzzParam(dict_weak, fuzzer);
|
| + } else {
|
| + auto dict = base::MakeUnique<base::DictionaryValue>();
|
| + FuzzParam(dict.get(), fuzzer);
|
| + p->Set(index, std::move(dict));
|
| + }
|
| break;
|
| }
|
| case base::Value::Type::LIST: {
|
| - base::ListValue* tmp = new base::ListValue();
|
| - p->GetList(index, &tmp);
|
| - FuzzParam(tmp, fuzzer);
|
| - p->Set(index, tmp);
|
| + base::ListValue* list_weak = nullptr;
|
| + if (p->GetList(index, &list_weak)) {
|
| + FuzzParam(list_weak, fuzzer);
|
| + } else {
|
| + auto list = base::MakeUnique<base::ListValue>();
|
| + FuzzParam(list.get(), fuzzer);
|
| + p->Set(index, std::move(list));
|
| + }
|
| break;
|
| }
|
| case base::Value::Type::NONE:
|
|
|