From 6434d2fa99f091529191d2e7ee1b8469fad5b218 Mon Sep 17 00:00:00 2001 From: tekka Date: Sun, 7 Jan 2018 14:51:28 +0100 Subject: [PATCH] Linux: Fix null ptr exception (#1025) --- drivers/RF24/RF24.cpp | 2 +- drivers/RFM69/new/RFM69_new.cpp | 2 +- drivers/RFM95/RFM95.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/RF24/RF24.cpp b/drivers/RF24/RF24.cpp index ce88f17c8..025ad607c 100644 --- a/drivers/RF24/RF24.cpp +++ b/drivers/RF24/RF24.cpp @@ -83,7 +83,7 @@ LOCAL uint8_t RF24_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, uint8_t } else { status = *prx++; // status is 1st byte of receive buffer // decrement before to skip status byte - while (--size) { + while (--size && (buf != NULL)) { *buf++ = *prx++; } } diff --git a/drivers/RFM69/new/RFM69_new.cpp b/drivers/RFM69/new/RFM69_new.cpp index d1dcd3b80..7cfb8b87d 100644 --- a/drivers/RFM69/new/RFM69_new.cpp +++ b/drivers/RFM69/new/RFM69_new.cpp @@ -136,7 +136,7 @@ LOCAL uint8_t RFM69_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, uint8_ } else { status = *prx++; // status is 1st byte of receive buffer // decrement before to skip status byte - while (--size) { + while (--size && (buf != NULL)) { *buf++ = *prx++; } } diff --git a/drivers/RFM95/RFM95.cpp b/drivers/RFM95/RFM95.cpp index 6dd83162a..cc55a41f1 100644 --- a/drivers/RFM95/RFM95.cpp +++ b/drivers/RFM95/RFM95.cpp @@ -83,7 +83,7 @@ LOCAL uint8_t RFM95_spiMultiByteTransfer(const uint8_t cmd, uint8_t* buf, uint8_ } else { status = *prx++; // status is 1st byte of receive buffer // decrement before to skip status byte - while (--size) { + while (--size && (buf != NULL)) { *buf++ = *prx++; } }