Skip to content

Commit 3552ea7

Browse files
PPPinterface: address getters check for invalid pointer
1 parent ffdd543 commit 3552ea7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

features/netsocket/PPPInterface.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ const char *PPPInterface::get_ip_address()
9494

9595
nsapi_error_t PPPInterface::get_ip_address(SocketAddress *address)
9696
{
97-
if (address) {
97+
if (!address) {
9898
return NSAPI_ERROR_PARAMETER;
9999
}
100100

@@ -108,6 +108,10 @@ nsapi_error_t PPPInterface::get_ip_address(SocketAddress *address)
108108

109109
nsapi_error_t PPPInterface::get_netmask(SocketAddress *address)
110110
{
111+
if (!address) {
112+
return NSAPI_ERROR_PARAMETER;
113+
}
114+
111115
if (_interface && _interface->get_netmask(address) == NSAPI_ERROR_OK) {
112116
strncpy(_netmask, address->get_ip_address(), sizeof(_netmask));
113117
return NSAPI_ERROR_OK;
@@ -118,6 +122,10 @@ nsapi_error_t PPPInterface::get_netmask(SocketAddress *address)
118122

119123
nsapi_error_t PPPInterface::get_gateway(SocketAddress *address)
120124
{
125+
if (!address) {
126+
return NSAPI_ERROR_PARAMETER;
127+
}
128+
121129
if (_interface && _interface->get_gateway(address) == NSAPI_ERROR_OK) {
122130
strncpy(_gateway, address->get_ip_address(), sizeof(_gateway));
123131
address->set_ip_address(_gateway);

0 commit comments

Comments
 (0)