mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-01 23:45:48 +03:00
coap_session.c: Fix adding NULL pointer on error in coap_new_server_session()
When coap_make_session() fails, the local variable session will be NULL, and the program continues at the error label. Because of session == NULL, coap_session_free() will return immediately, leaving a NULL entry in ep->sessions. This fix is related to CID 1520613.
This commit is contained in:
1 parent
ea89cb842c
commit
5f0eea8dbb
1 file changed
+4
-2
+4
-2
@@ -1383,8 +1383,10 @@ error:
|
||||
* Need to add in the session as coap_session_release()
|
||||
* will call SESSIONS_DELETE in coap_session_free().
|
||||
*/
|
||||
SESSIONS_ADD(ep->sessions, session);
|
||||
coap_session_free(session);
|
||||
if (session) {
|
||||
SESSIONS_ADD(ep->sessions, session);
|
||||
coap_session_free(session);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif /* COAP_SERVER_SUPPORT */
|
||||
|
||||
Reference in new issue
Block a user