-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Null-check pool.allocZeroed() at 13 sites across 9 files #10262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 4 commits
a96a99b
bb899f4
1d1713a
055bf7b
293cf2c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -482,6 +482,10 @@ bool MQTT::publish(const char *topic, const char *payload, bool retained) | |||||||
| { | ||||||||
| if (moduleConfig.mqtt.proxy_to_client_enabled) { | ||||||||
| meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed(); | ||||||||
| if (!msg) { | ||||||||
| LOG_WARN("MQTT proxy publish skipped: message pool exhausted"); | ||||||||
| return false; | ||||||||
|
thebentern marked this conversation as resolved.
|
||||||||
| } | ||||||||
| msg->which_payload_variant = meshtastic_MqttClientProxyMessage_text_tag; | ||||||||
| strncpy(msg->topic, topic, sizeof(msg->topic)); | ||||||||
| msg->topic[sizeof(msg->topic) - 1] = '\0'; | ||||||||
|
|
@@ -503,6 +507,10 @@ bool MQTT::publish(const char *topic, const uint8_t *payload, size_t length, boo | |||||||
| { | ||||||||
| if (moduleConfig.mqtt.proxy_to_client_enabled) { | ||||||||
| meshtastic_MqttClientProxyMessage *msg = mqttClientProxyMessagePool.allocZeroed(); | ||||||||
| if (!msg) { | ||||||||
| LOG_WARN("MQTT proxy publish skipped: message pool exhausted"); | ||||||||
| return false; | ||||||||
| } | ||||||||
|
Comment on lines
+510
to
+513
|
||||||||
| msg->which_payload_variant = meshtastic_MqttClientProxyMessage_data_tag; | ||||||||
| strncpy(msg->topic, topic, sizeof(msg->topic)); | ||||||||
| msg->topic[sizeof(msg->topic) - 1] = '\0'; // Ensure null termination | ||||||||
|
|
@@ -685,11 +693,13 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC | |||||||
| LOG_ERROR(warning); | ||||||||
| #if !IS_RUNNING_TESTS | ||||||||
| meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); | ||||||||
| cn->level = meshtastic_LogRecord_Level_ERROR; | ||||||||
| cn->time = getValidTime(RTCQualityFromNet); | ||||||||
| strncpy(cn->message, warning, sizeof(cn->message) - 1); | ||||||||
| cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination | ||||||||
| service->sendClientNotification(cn); | ||||||||
| if (cn) { | ||||||||
| cn->level = meshtastic_LogRecord_Level_ERROR; | ||||||||
| cn->time = getValidTime(RTCQualityFromNet); | ||||||||
| strncpy(cn->message, warning, sizeof(cn->message) - 1); | ||||||||
| cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination | ||||||||
| service->sendClientNotification(cn); | ||||||||
| } | ||||||||
| #endif | ||||||||
| return false; | ||||||||
| #endif | ||||||||
|
|
@@ -701,11 +711,13 @@ bool MQTT::isValidConfig(const meshtastic_ModuleConfig_MQTTConfig &config, MQTTC | |||||||
| LOG_ERROR(warning); | ||||||||
| #if !IS_RUNNING_TESTS | ||||||||
| meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); | ||||||||
| cn->level = meshtastic_LogRecord_Level_ERROR; | ||||||||
| cn->time = getValidTime(RTCQualityFromNet); | ||||||||
| strncpy(cn->message, warning, sizeof(cn->message) - 1); | ||||||||
| cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination | ||||||||
| service->sendClientNotification(cn); | ||||||||
| if (cn) { | ||||||||
| cn->level = meshtastic_LogRecord_Level_ERROR; | ||||||||
| cn->time = getValidTime(RTCQualityFromNet); | ||||||||
| strncpy(cn->message, warning, sizeof(cn->message) - 1); | ||||||||
| cn->message[sizeof(cn->message) - 1] = '\0'; // Ensure null termination | ||||||||
| service->sendClientNotification(cn); | ||||||||
| } | ||||||||
| #endif | ||||||||
| return false; | ||||||||
| } | ||||||||
|
|
@@ -878,6 +890,10 @@ void MQTT::perhapsReportToMap() | |||||||
|
|
||||||||
| // Allocate MeshPacket and fill it | ||||||||
| meshtastic_MeshPacket *mp = packetPool.allocZeroed(); | ||||||||
| if (!mp) { | ||||||||
| LOG_ERROR("MQTT Map report: packet pool exhausted"); | ||||||||
|
||||||||
| LOG_ERROR("MQTT Map report: packet pool exhausted"); | |
| LOG_ERROR("MQTT Map report: packet pool exhausted"); | |
| last_report_to_map = millis(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment says we’d otherwise “spin every tick retrying”, but this check runs in
setup()(single-shot). Consider rewording to reflect the actual behavior (e.g., avoiding repeated warnings across restarts / multiple setup invocations) or remove the “every tick” phrasing to prevent confusion.