File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -462,6 +462,14 @@ static int handle_disconnecting(void)
462462 ctx .socket_fd = -1 ;
463463 }
464464
465+ /* Release the wolfMQTT/wolfIP io_desc slot (in_use sentinel) so it is
466+ * not leaked from the fixed MAX_WOLFMQTT_CTX pool. NULL it to avoid a
467+ * double free if this path is re-entered. */
468+ if (ctx .io_ctx ) {
469+ wolfMQTT_Cleanup_wolfIP (ctx .io_ctx );
470+ ctx .io_ctx = NULL ;
471+ }
472+
465473 ctx .state = MQTT_STATE_IDLE ;
466474 }
467475
@@ -513,6 +521,13 @@ int mqtt_client_poll(void)
513521 wolfIP_sock_close (ctx .stack , ctx .socket_fd );
514522 ctx .socket_fd = -1 ;
515523 }
524+ /* Release the wolfMQTT/wolfIP io_desc slot (in_use sentinel) so it
525+ * is not leaked from the fixed MAX_WOLFMQTT_CTX pool. NULL it to
526+ * avoid a double free if this path is re-entered. */
527+ if (ctx .io_ctx ) {
528+ wolfMQTT_Cleanup_wolfIP (ctx .io_ctx );
529+ ctx .io_ctx = NULL ;
530+ }
516531 ctx .publish_pending = 0 ;
517532 ctx .state = MQTT_STATE_IDLE ;
518533 break ;
You can’t perform that action at this time.
0 commit comments