diff options
author | Chuck Todd <ctodd@cableone.net> | 2015-08-03 15:38:29 -0600 |
---|---|---|
committer | Martino Facchin <m.facchin@arduino.cc> | 2015-08-12 11:47:57 +0200 |
commit | 98f7ab15884119b1c9f1f58f96a8302200c1e2a3 (patch) | |
tree | e00f2466c2a6cb3cf849577ca5fd5a2a8da39a6d /cores | |
parent | 78700c655602c850c357f5c557ef756860b33357 (diff) |
Print not Aborting on Write() failure
Print::write(const uint8_t *buffer, size_t size) and Print::print(const
__FlashStringHelper *ifsh) would continue calling write(char) after a
failed write(char) this behavior would render returned count unuseable
see arduino/Arduino issue #3614
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/Print.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cores/arduino/Print.cpp b/cores/arduino/Print.cpp index 782d50b..bc97c85 100644 --- a/cores/arduino/Print.cpp +++ b/cores/arduino/Print.cpp @@ -17,6 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 23 November 2006 by David A. Mellis + Modified 03 August 2015 by Chuck Todd */ #include <stdlib.h> @@ -34,7 +35,8 @@ size_t Print::write(const uint8_t *buffer, size_t size) { size_t n = 0; while (size--) { - n += write(*buffer++); + if (write(*buffer++)) n++; + else break; } return n; } @@ -46,7 +48,8 @@ size_t Print::print(const __FlashStringHelper *ifsh) while (1) { unsigned char c = pgm_read_byte(p++); if (c == 0) break; - n += write(c); + if (write(c)) n++; + else break; } return n; } |