Fix heap leak mentioned in #2358 (#2359)

* Fix heap leak mentioned in #2358

* Additional fix for #2359
This commit is contained in:
Manuel
2023-03-14 16:50:32 -05:00
committed by GitHub
co-authored by GitHub
parent e03a2f8f7f
commit b398f31b64
+4 -5
View File
@@ -82,7 +82,7 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp)
} }
printPacket("Forwarding to phone", mp); printPacket("Forwarding to phone", mp);
sendToPhone((meshtastic_MeshPacket *)mp); sendToPhone(packetPool.allocCopy(*mp));
return 0; return 0;
} }
@@ -231,7 +231,7 @@ void MeshService::sendToMesh(meshtastic_MeshPacket *p, RxSource src, bool ccToPh
} }
if (ccToPhone) { if (ccToPhone) {
sendToPhone(p); sendToPhone(packetPool.allocCopy(*p));
} }
} }
@@ -262,9 +262,8 @@ void MeshService::sendToPhone(meshtastic_MeshPacket *p)
releaseToPool(d); releaseToPool(d);
} }
meshtastic_MeshPacket *copied = packetPool.allocCopy(*p); perhapsDecode(p);
perhapsDecode(copied); assert(toPhoneQueue.enqueue(p, 0));
assert(toPhoneQueue.enqueue(copied, 0));
fromNum++; fromNum++;
} }