From a1fb286c06326f5d19277132f2599c0bc991279c Mon Sep 17 00:00:00 2001 From: jeromecoutant Date: Tue, 28 Jan 2020 11:06:06 +0100 Subject: [PATCH] AT_CellularStack: crash during TCP test function tries to access _socket[1] whch is not opened --- features/cellular/framework/AT/AT_CellularStack.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/features/cellular/framework/AT/AT_CellularStack.cpp b/features/cellular/framework/AT/AT_CellularStack.cpp index 912bd1072b..0cd3ac4c7f 100644 --- a/features/cellular/framework/AT/AT_CellularStack.cpp +++ b/features/cellular/framework/AT/AT_CellularStack.cpp @@ -429,8 +429,10 @@ void AT_CellularStack::socket_attach(nsapi_socket_t handle, void (*callback)(voi int AT_CellularStack::get_socket_index_by_port(uint16_t port) { for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) { - if (_socket[i]->localAddress.get_port() == port) { - return i; + if (_socket[i] != 0) { + if (_socket[i]->localAddress.get_port() == port) { + return i; + } } } return -1;