From 98f7ab15884119b1c9f1f58f96a8302200c1e2a3 Mon Sep 17 00:00:00 2001 From: Chuck Todd Date: Mon, 3 Aug 2015 15:38:29 -0600 Subject: 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 --- cores/arduino/Print.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cores/arduino') 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 @@ -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; } -- cgit v1.2.3-18-g5258