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

Unified Diff: runtime/bin/dartutils.cc

Issue 91043003: Simplify some argument checking for socket calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 7 years, 1 month 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/bin/dartutils.h ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.cc
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index 15f55e5a3ad6e74aa32c0bb73732170032d7393b..ed010db4ee0e72d7704b3740e9b09cddcd66c2eb 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -72,12 +72,22 @@ int64_t DartUtils::GetIntegerValue(Dart_Handle value_obj) {
}
+int64_t DartUtils::GetInt64ValueCheckRange(
+ Dart_Handle value_obj, int64_t lower, int64_t upper) {
+ int64_t value = DartUtils::GetIntegerValue(value_obj);
+ if (value < lower || upper < value) {
+ Dart_PropagateError(Dart_NewApiError("Value outside expected range"));
+ }
+ return value;
+}
+
+
intptr_t DartUtils::GetIntptrValue(Dart_Handle value_obj) {
int64_t value = 0;
Dart_Handle result = Dart_IntegerToInt64(value_obj, &value);
if (Dart_IsError(result)) Dart_PropagateError(result);
if (value < kIntptrMin || kIntptrMax < value) {
- Dart_PropagateError(Dart_NewApiError("Value outside intptr:t range"));
+ Dart_PropagateError(Dart_NewApiError("Value outside intptr_t range"));
}
return static_cast<intptr_t>(value);
}
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698