1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-28 09:24:14 +01:00

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
This commit is contained in:
Chuck Todd 2015-08-03 15:38:29 -06:00 committed by Martino Facchin
parent cb6b2cf607
commit 25d81c98e4

View File

@ -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;
}