From 784e8a3eb8ddb181ab959e9253f078d80a149066 Mon Sep 17 00:00:00 2001 From: Jon Trulson Date: Wed, 10 Jun 2015 14:34:05 -0600 Subject: [PATCH] hmtrp: example: make sure string read is 0 terminated defect #146 Signed-off-by: Jon Trulson Signed-off-by: Mihai Tudor Panu --- examples/c++/hmtrp.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/c++/hmtrp.cxx b/examples/c++/hmtrp.cxx index 84f7995b..3d58ba96 100644 --- a/examples/c++/hmtrp.cxx +++ b/examples/c++/hmtrp.cxx @@ -23,6 +23,7 @@ */ #include +#include #include #include #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;