Fix of a bug

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));
}
This commit is contained in:
Amulya Kumar Sahoo 2014-05-30 11:44:50 +05:30
parent 44b5096e05
commit 91f0dbc9ec
1 changed files with 1 additions and 1 deletions

View File

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