mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-17 13:29:05 +03:00
coap_free_endpoint: fix segfault with incorrect -A argument
`coap-server(1)` segfaults when invoked as: $ coap-server -A '2001:db8::1' Feb 09 18:28:49 WARN coap_socket_bind_udp: bind: Address not available Segmentation fault In this case, the `ep->context->endpoint` is NULL but `coap_free_endpoint` still attempts to access it. To prevent this invocation from causing a segmentation fault, check if `ep->context->endpoint` is NULL before accessing it.
This commit is contained in:
1 parent
978b228f5f
commit
605d56eb8d
1 file changed
+1
-1
+1
-1
@@ -1129,7 +1129,7 @@ coap_free_endpoint(coap_endpoint_t *ep) {
|
||||
coap_socket_close(&ep->sock);
|
||||
}
|
||||
|
||||
if (ep->context) {
|
||||
if (ep->context && ep->context->endpoint) {
|
||||
LL_DELETE(ep->context->endpoint, ep);
|
||||
}
|
||||
coap_mfree_endpoint(ep);
|
||||
|
||||
Reference in new issue
Block a user