From 6e85bcd902450e719849bd4048702b5e49d500e1 Mon Sep 17 00:00:00 2001 From: Adelin Dobre Date: Mon, 7 Jan 2019 17:58:00 +0200 Subject: [PATCH] jsonplatform.c: Add fix for dereferencing of a null pointer Signed-off-by: Adelin Dobre Signed-off-by: Mihai Tudor Panu --- src/json/jsonplatform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/json/jsonplatform.c b/src/json/jsonplatform.c index 3be8cfe..8de6be3 100644 --- a/src/json/jsonplatform.c +++ b/src/json/jsonplatform.c @@ -291,7 +291,11 @@ mraa_init_json_platform_i2c(json_object* jobj_i2c, mraa_board_t* board, int inde json_object* jobj_temp = NULL; // Default to no mux pins defined - board->pins[pin].i2c.mux_total = 0; + if(board->pins != NULL) { + board->pins[pin].i2c.mux_total = 0; + } else { + return MRAA_ERROR_NO_DATA_AVAILABLE; + } // Get the I2C bus array index ret = mraa_init_json_platform_get_index(jobj_i2c, I2C_KEY, INDEX_KEY, index, &pos, board->i2c_bus_count - 1);