Null-check packet allocations in allocForSending and its callers (#11086)

* Null-check packet allocations in allocForSending and its callers

Sibling of 0ae44d701.

* Null-check allocDataProtobuf, allocAckNak and allocErrorResponse callers

Second tier of the same nullable contract.

* Keep telemetry sleep scheduling on allocation failure

Allocation failure now marks the telemetry invalid instead of returning
early, so power-saving SENSOR nodes still arm deep sleep.
This commit is contained in:
Thomas Göttgens
2026-07-20 18:37:13 -05:00
committed by GitHub
co-authored by GitHub
parent 09de848fbe
commit fb75410e53
30 changed files with 194 additions and 86 deletions
+8
View File
@@ -131,6 +131,10 @@ void DetectionSensorModule::sendDetectionMessage()
char *message = new char[40];
sprintf(message, "%s detected", moduleConfig.detection_sensor.name);
meshtastic_MeshPacket *p = allocDataPacket();
if (!p) {
delete[] message;
return;
}
p->want_ack = false;
p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);
@@ -153,6 +157,10 @@ void DetectionSensorModule::sendCurrentStateMessage(bool state)
char *message = new char[40];
sprintf(message, "%s state: %i", moduleConfig.detection_sensor.name, state);
meshtastic_MeshPacket *p = allocDataPacket();
if (!p) {
delete[] message;
return;
}
p->want_ack = false;
p->decoded.payload.size = strlen(message);
memcpy(p->decoded.payload.bytes, message, p->decoded.payload.size);