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

Unified Diff: runtime/vm/exceptions.cc

Issue 33313003: Report use of malbounded interface in type test. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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 | « runtime/vm/exceptions.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
===================================================================
--- runtime/vm/exceptions.cc (revision 28940)
+++ runtime/vm/exceptions.cc (working copy)
@@ -491,15 +491,17 @@
// Allocate, initialize, and throw a TypeError or CastError.
+// If bound_error is not null, throw a TypeError, even for a type cast.
void Exceptions::CreateAndThrowTypeError(intptr_t location,
const String& src_type_name,
const String& dst_type_name,
const String& dst_name,
- const String& malformed_error) {
+ const String& bound_error) {
const Array& args = Array::Handle(Array::New(7));
ExceptionType exception_type =
- dst_name.Equals(kCastErrorDstName) ? kCast : kType;
+ (bound_error.IsNull() && dst_name.Equals(kCastErrorDstName)) ?
+ kCast : kType;
DartFrameIterator iterator;
const Script& script = Script::Handle(GetCallerScript(&iterator));
@@ -510,17 +512,17 @@
args.SetAt(1, Smi::Handle(Smi::New(line)));
args.SetAt(2, Smi::Handle(Smi::New(column)));
- // Initialize '_srcType', '_dstType', '_dstName', and '_malformedError'.
+ // Initialize '_srcType', '_dstType', '_dstName', and '_boundError'.
args.SetAt(3, src_type_name);
args.SetAt(4, dst_type_name);
args.SetAt(5, dst_name);
- args.SetAt(6, malformed_error);
+ args.SetAt(6, bound_error);
// Type errors in the core library may be difficult to diagnose.
// Print type error information before throwing the error when debugging.
if (FLAG_print_stacktrace_at_throw) {
- if (!malformed_error.IsNull()) {
- OS::Print("%s\n", malformed_error.ToCString());
+ if (!bound_error.IsNull()) {
+ OS::Print("%s\n", bound_error.ToCString());
}
intptr_t line, column;
script.GetTokenLocation(location, &line, &column);
@@ -532,7 +534,7 @@
dst_type_name.ToCString(),
dst_name.ToCString());
} else {
- OS::Print("malformed type used.\n");
+ OS::Print("malbounded type used.\n");
}
}
// Throw TypeError or CastError instance.
« no previous file with comments | « runtime/vm/exceptions.h ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698