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 22:50:32 +01:00 committed by GitHub
parent e03a2f8f7f
commit b398f31b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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++;
} }