-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 all 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) { | ||||||||
| // MemoryPool::alloc already LOG_WARNs on exhaustion; don't double-log here. | ||||||||
| 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) { | ||||||||
| // MemoryPool::alloc already LOG_WARNs on exhaustion; don't double-log here. | ||||||||
| 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,15 @@ void MQTT::perhapsReportToMap() | |||||||
|
|
||||||||
| // Allocate MeshPacket and fill it | ||||||||
| meshtastic_MeshPacket *mp = packetPool.allocZeroed(); | ||||||||
| if (!mp) { | ||||||||
| // Back off to the configured publish interval on pool exhaustion. Without this, | ||||||||
| // perhapsReportToMap() would be called on every runOnce() (20–200 ms) until the | ||||||||
| // pool recovers, and each call would retry the log + early return — turning | ||||||||
| // sustained pool pressure into a log-flood instead of a throttled failure. | ||||||||
| 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(); |
Uh oh!
There was an error while loading. Please reload this page.