Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: tools/ipc_fuzzer/fuzzer/fuzzer.cc

Issue 2838893002: Remove base::ListValue::Set(size_t, base::Value*) (Closed)
Patch Set: Fix Compilation Error Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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:
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698