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

Unified Diff: src/field-type.cc

Issue 2292953002: Make FieldType::None() non-nullptr value to avoid undefined behaviour (Closed)
Patch Set: (fix build by removing unused var in test) Created 4 years, 4 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 | « no previous file | test/cctest/test-field-type-tracking.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/field-type.cc
diff --git a/src/field-type.cc b/src/field-type.cc
index f1cb962b54f322570a41f75856c4baa25a94e9b5..2e4cbfbedde2935d245bd7c47d3e0305211d9eda 100644
--- a/src/field-type.cc
+++ b/src/field-type.cc
@@ -13,7 +13,9 @@ namespace internal {
// static
FieldType* FieldType::None() {
- return reinterpret_cast<FieldType*>(Smi::FromInt(0));
+ // Do not Smi::FromInt(0) here or for Any(), as that may translate
+ // as `nullptr` which is not a valid value for `this`.
+ return reinterpret_cast<FieldType*>(Smi::FromInt(2));
}
// static
« no previous file with comments | « no previous file | test/cctest/test-field-type-tracking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698