AT_CellularStack: crash during TCP test

function tries to access _socket[1] whch is not opened
pull/12329/head
jeromecoutant 2020-01-28 11:06:06 +01:00
parent 706625a982
commit a1fb286c06
1 changed files with 4 additions and 2 deletions

View File

@ -429,10 +429,12 @@ void AT_CellularStack::socket_attach(nsapi_socket_t handle, void (*callback)(voi
int AT_CellularStack::get_socket_index_by_port(uint16_t port) 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++) { for (int i = 0; i < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT); i++) {
if (_socket[i] != 0) {
if (_socket[i]->localAddress.get_port() == port) { if (_socket[i]->localAddress.get_port() == port) {
return i; return i;
} }
} }
}
return -1; return -1;
} }