Skip to content

Commit a4ff62e

Browse files
KariHaapalehtoadbridge
authored andcommitted
Add check for _interface
1 parent bd6503f commit a4ff62e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

features/netsocket/EMACInterface.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,23 @@ nsapi_error_t EMACInterface::connect()
7070

7171
nsapi_error_t EMACInterface::disconnect()
7272
{
73-
return _interface->bringdown();
73+
if (_interface) {
74+
return _interface->bringdown();
75+
}
76+
return NSAPI_ERROR_NO_CONNECTION;
7477
}
7578

7679
const char *EMACInterface::get_mac_address()
7780
{
78-
if (_interface->get_mac_address(_mac_address, sizeof(_mac_address))) {
81+
if (_interface && _interface->get_mac_address(_mac_address, sizeof(_mac_address))) {
7982
return _mac_address;
8083
}
8184
return NULL;
8285
}
8386

8487
const char *EMACInterface::get_ip_address()
8588
{
86-
if (_interface->get_ip_address(_ip_address, sizeof(_ip_address))) {
89+
if (_interface && _interface->get_ip_address(_ip_address, sizeof(_ip_address))) {
8790
return _ip_address;
8891
}
8992

@@ -92,7 +95,7 @@ const char *EMACInterface::get_ip_address()
9295

9396
const char *EMACInterface::get_netmask()
9497
{
95-
if (_interface->get_netmask(_netmask, sizeof(_netmask))) {
98+
if (_interface && _interface->get_netmask(_netmask, sizeof(_netmask))) {
9699
return _netmask;
97100
}
98101

@@ -101,7 +104,7 @@ const char *EMACInterface::get_netmask()
101104

102105
const char *EMACInterface::get_gateway()
103106
{
104-
if (_interface->get_gateway(_gateway, sizeof(_gateway))) {
107+
if (_interface && _interface->get_gateway(_gateway, sizeof(_gateway))) {
105108
return _gateway;
106109
}
107110

0 commit comments

Comments
 (0)