ilikecats567 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Print class writes one character for the NULL pointer #941

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Compile and run the code below.

  Serial.begin(9600);
  char* pData = NULL;
  Serial.print(pData);

What is the expected output? What do you see instead?
==>Expected result: nothing should be output since the pointer is NULL.
==>Actual result: I can see a character in serial monitor. The character 
changes when upload different sketches. 

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?

==> Arduino 1.0, Win XP 64, Duemilanove 328.

Please provide any additional information below.

Original issue reported on code.google.com by Jeffrey....@gmail.com on 1 Jun 2012 at 1:01

GoogleCodeExporter commented 9 years ago
Hmm, I can't replicate this.  Can you post a complete sketch with the problem?

Original comment by dmel...@gmail.com on 2 Jun 2012 at 9:44

GoogleCodeExporter commented 9 years ago
Build and upload the code below. 
Open the serial monitor.
Actual Result: The chars "ooooooo" are printed to the monitor. 

Arduino sketch
{{{

#include <Arduino.h>
#include <HardwareSerial.h>

void setup() {
    Serial.begin(9600);
}

void loop() {
  char* pData = NULL;
  Serial.print(pData);

  delay(1000);
}
}}}

Original comment by Jeffrey....@gmail.com on 3 Jun 2012 at 6:36

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/commit/b787982eec6c53319f8e8e580d7603cc16d733
ff

Original comment by dmel...@gmail.com on 3 Jun 2012 at 11:49