aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/Print.h
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2012-06-03 07:48:32 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2012-06-03 07:48:32 -0400
commit57973bcd49f1b789232205528ec6ad0ea053c97d (patch)
treeca4d61cacb6228dc08569c9cd3486962764a5d22 /cores/arduino/Print.h
parent4ed0bd2bd562ad815e62e0a2dbb34d854d2c6929 (diff)
Check for NULL pointer in Print.write().
Otherwise, trying to print(NULL) or write(NULL) could print a random character. http://code.google.com/p/arduino/issues/detail?id=941
Diffstat (limited to 'cores/arduino/Print.h')
-rwxr-xr-xcores/arduino/Print.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/cores/arduino/Print.h b/cores/arduino/Print.h
index 1af6b72..dc76150 100755
--- a/cores/arduino/Print.h
+++ b/cores/arduino/Print.h
@@ -46,7 +46,10 @@ class Print
void clearWriteError() { setWriteError(0); }
virtual size_t write(uint8_t) = 0;
- size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); }
+ size_t write(const char *str) {
+ if (str == NULL) return 0;
+ return write((const uint8_t *)str, strlen(str));
+ }
virtual size_t write(const uint8_t *buffer, size_t size);
size_t print(const __FlashStringHelper *);