DescriptionCheck Swaps and MergeDictionary for base::Value
The following is a dangerous practice:
1: DictionaryValue d;
2: Value *p = &d;
3: *p = Value(1.234);
4: DictionaryValue().Swap(&d);
After line 3, |d| is no longer a DictionaryValue.
Before r451296, it caused no bad memory access, because the storage
for the double and for the dictionary did not overlap. After that CL, this code would crash. In any case, it is dangerous.
Similar issue is there for DictionaryValue::MergeDictionary and ListValue::Swap.
This issue is only temporary, because DictionaryValue will eventually become
just Value. But until then, the code needs to be sure to avoid such scenarios.
Therefore this CL introduces CHECKS for the correct value types.
The CL also introduces two more CHECKS in Internal*AssignFrom to prevent
executing a desctructor on an arbitrary address.
All the above are CHECKS, as opposed to DCHECKS, because if the checked
conditions do not hold, execution of arbitrary parts of memory might be
possible.
BUG=697817
Review-Url: https://codereview.chromium.org/2728773005
Cr-Commit-Position: refs/heads/master@{#455288}
Committed: https://chromium.googlesource.com/chromium/src/+/182756aeb9ef4240cace58875e71d42a7402711c
Patch Set 1 #Patch Set 2 : CHECKS #
Total comments: 4
Patch Set 3 : Add ...SameType #Messages
Total messages: 21 (15 generated)
|