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

Unified Diff: runtime/bin/file.cc

Issue 9072003: Handle reading byte past the end of file (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 12 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 | tests/standalone/src/FileTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/file.cc
diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc
index 784f25854a7b8e6b46453bc9ce13ba04c3f24bea..2434d1df466e4fe68aeca12287a1ce8b4ccd047f 100644
--- a/runtime/bin/file.cc
+++ b/runtime/bin/file.cc
@@ -85,8 +85,10 @@ void FUNCTION_NAME(File_ReadByte)(Dart_NativeArguments args) {
if (file != NULL) {
uint8_t buffer;
int bytes_read = file->Read(reinterpret_cast<void*>(&buffer), 1);
- if (bytes_read >= 0) {
+ if (bytes_read == 1) {
return_value = static_cast<intptr_t>(buffer);
+ } else {
+ return_value = -1;
}
}
Dart_SetReturnValue(args, Dart_NewInteger(return_value));
« no previous file with comments | « no previous file | tests/standalone/src/FileTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698