Permalink
Browse files

Fixed overflow issue with available()

  • Loading branch information...
1 parent 95ecca5 commit 64d1e07c86465230befc91566dbfabadf2e83cd0 @ladyada ladyada committed Jun 1, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 File.cpp
View
5 File.cpp
@@ -97,7 +97,10 @@ int File::read(void *buf, uint16_t nbyte) {
int File::available() {
if (! _file) return 0;
- return size() - position();
+
+ uint32_t n = size() - position();
+
+ return n > 0X7FFF ? 0X7FFF : n;
}
void File::flush() {

0 comments on commit 64d1e07

Please sign in to comment.