From f72d9611f0a7c216a621888103922291e078f2a2 Mon Sep 17 00:00:00 2001 From: Brian Schmalz Date: Mon, 2 Feb 2015 21:51:49 -0600 Subject: [PATCH] Fixed off-by-one bug in setFirmwareNameAndVersion() where we were writing a zero terminator past the end of the block we'd gotten from malloc(). --- Firmata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmata.cpp b/Firmata.cpp index 23302289..4299d37f 100644 --- a/Firmata.cpp +++ b/Firmata.cpp @@ -146,7 +146,7 @@ void FirmataClass::setFirmwareNameAndVersion(const char *name, byte major, byte // in case anyone calls setFirmwareNameAndVersion more than once free(firmwareVersionVector); - firmwareVersionVector = (byte *) malloc(firmwareVersionCount); + firmwareVersionVector = (byte *) malloc(firmwareVersionCount+1); firmwareVersionVector[firmwareVersionCount] = 0; firmwareVersionVector[0] = major; firmwareVersionVector[1] = minor;