hmtrp: example: make sure string read is 0 terminated

defect #146

Signed-off-by: Jon Trulson <jtrulson@ics.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Jon Trulson 2015-06-10 14:34:05 -06:00 committed by Mihai Tudor Panu
parent 7fbe71102a
commit 784e8a3eb8

View File

@ -23,6 +23,7 @@
*/
#include <unistd.h>
#include <string.h>
#include <iostream>
#include <signal.h>
#include "hmtrp.h"
@ -128,7 +129,8 @@ int main (int argc, char **argv)
// check to see if data is available first.
if (radio->dataAvailable())
{
int rv = radio->readData(radioBuffer, bufferLength);
memset(radioBuffer, 0, bufferLength);
int rv = radio->readData(radioBuffer, bufferLength - 1);
if (rv > 0)
cout << "Received: " << radioBuffer << endl;