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:
parent
78700c6556
commit
98f7ab1588
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue