Skip to content

Commit

Permalink
Fix of a bug
Browse files Browse the repository at this point in the history
Stream::find(char *target) passes NULL as “terminator” to Stream::findUntil(char *target, char *terminator), which immediately dereferences it by passing it on to strlen() :
 
bool Stream::find(char *target)
{
  return findUntil(target, NULL);
}
 
// as find but search ends if the terminator string is found
bool Stream::findUntil(char *target, char *terminator)
{
  return findUntil(target, strlen(target), terminator, strlen(terminator));
}
  • Loading branch information
amulya349 committed May 30, 2014
1 parent 91f0dbc commit 2c3058b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hardware/arduino/cores/robot/Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void Stream::setTimeout(unsigned long timeout) // sets the maximum number of mi
// find returns true if the target string is found
bool Stream::find(char *target)
{
return findUntil(target, NULL);
return findUntil(target, "");
}

// reads data from the stream until the target string of given length is found
Expand Down

0 comments on commit 2c3058b

Please sign in to comment.