@@ -482,6 +482,8 @@ bool MQTT::publish(const char *topic, const char *payload, bool retained)
482482{
483483 if (moduleConfig.mqtt .proxy_to_client_enabled ) {
484484 meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed ();
485+ if (!msg)
486+ return false ;
485487 msg->which_payload_variant = meshtastic_MqttClientProxyMessage_text_tag;
486488 strncpy (msg->topic , topic, sizeof (msg->topic ));
487489 msg->topic [sizeof (msg->topic ) - 1 ] = ' \0 ' ;
@@ -503,6 +505,8 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo
503505{
504506 if (moduleConfig.mqtt .proxy_to_client_enabled ) {
505507 meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed ();
508+ if (!msg)
509+ return false ;
506510 msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag;
507511 strncpy (msg->topic , topic, sizeof (msg->topic ));
508512 msg->topic [sizeof (msg->topic ) - 1 ] = ' \0 ' ; // Ensure null termination
@@ -685,11 +689,13 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC
685689 LOG_ERROR (warning);
686690#if !IS_RUNNING_TESTS
687691 meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed ();
688- cn->level = meshtastic_LogRecord_Level_ERROR;
689- cn->time = getValidTime (RTCQualityFromNet);
690- strncpy (cn->message , warning, sizeof (cn->message ) - 1 );
691- cn->message [sizeof (cn->message ) - 1 ] = ' \0 ' ; // Ensure null termination
692- service->sendClientNotification (cn);
692+ if (cn) {
693+ cn->level = meshtastic_LogRecord_Level_ERROR;
694+ cn->time = getValidTime (RTCQualityFromNet);
695+ strncpy (cn->message , warning, sizeof (cn->message ) - 1 );
696+ cn->message [sizeof (cn->message ) - 1 ] = ' \0 ' ; // Ensure null termination
697+ service->sendClientNotification (cn);
698+ }
693699#endif
694700 return false ;
695701#endif
@@ -701,11 +707,13 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC
701707 LOG_ERROR (warning);
702708#if !IS_RUNNING_TESTS
703709 meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed ();
704- cn->level = meshtastic_LogRecord_Level_ERROR;
705- cn->time = getValidTime (RTCQualityFromNet);
706- strncpy (cn->message , warning, sizeof (cn->message ) - 1 );
707- cn->message [sizeof (cn->message ) - 1 ] = ' \0 ' ; // Ensure null termination
708- service->sendClientNotification (cn);
710+ if (cn) {
711+ cn->level = meshtastic_LogRecord_Level_ERROR;
712+ cn->time = getValidTime (RTCQualityFromNet);
713+ strncpy (cn->message , warning, sizeof (cn->message ) - 1 );
714+ cn->message [sizeof (cn->message ) - 1 ] = ' \0 ' ; // Ensure null termination
715+ service->sendClientNotification (cn);
716+ }
709717#endif
710718 return false ;
711719 }
@@ -878,6 +886,10 @@ void MQTT::perhapsReportToMap()
878886
879887 // Allocate MeshPacket and fill it
880888 meshtastic_MeshPacket *mp = packetPool.allocZeroed ();
889+ if (!mp) {
890+ LOG_WARN (" MQTT Map report: packet pool exhausted" );
891+ return ;
892+ }
881893 mp->which_payload_variant = meshtastic_MeshPacket_decoded_tag;
882894 mp->from = nodeDB->getNodeNum ();
883895 mp->to = NODENUM_BROADCAST;
0 commit comments