mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-13 08:32:08 +00:00
Fix possible memory leak in NeighborInfo Module (#2765)
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
97f0c734e0
commit
17617ce031
@ -104,16 +104,6 @@ NeighborInfoModule::NeighborInfoModule()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Allocate a zeroed neighbor info packet
|
|
||||||
*/
|
|
||||||
meshtastic_NeighborInfo *NeighborInfoModule::allocateNeighborInfoPacket()
|
|
||||||
{
|
|
||||||
meshtastic_NeighborInfo *neighborInfo = (meshtastic_NeighborInfo *)malloc(sizeof(meshtastic_NeighborInfo));
|
|
||||||
memset(neighborInfo, 0, sizeof(meshtastic_NeighborInfo));
|
|
||||||
return neighborInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Collect neighbor info from the nodeDB's history, capping at a maximum number of entries and max time
|
Collect neighbor info from the nodeDB's history, capping at a maximum number of entries and max time
|
||||||
Assumes that the neighborInfo packet has been allocated
|
Assumes that the neighborInfo packet has been allocated
|
||||||
@ -185,14 +175,14 @@ size_t NeighborInfoModule::cleanUpNeighbors()
|
|||||||
/* Send neighbor info to the mesh */
|
/* Send neighbor info to the mesh */
|
||||||
void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies)
|
void NeighborInfoModule::sendNeighborInfo(NodeNum dest, bool wantReplies)
|
||||||
{
|
{
|
||||||
meshtastic_NeighborInfo *neighborInfo = allocateNeighborInfoPacket();
|
meshtastic_NeighborInfo neighborInfo = meshtastic_NeighborInfo_init_zero;
|
||||||
collectNeighborInfo(neighborInfo);
|
collectNeighborInfo(&neighborInfo);
|
||||||
meshtastic_MeshPacket *p = allocDataProtobuf(*neighborInfo);
|
meshtastic_MeshPacket *p = allocDataProtobuf(neighborInfo);
|
||||||
// send regardless of whether or not we have neighbors in our DB,
|
// send regardless of whether or not we have neighbors in our DB,
|
||||||
// because we want to get neighbors for the next cycle
|
// because we want to get neighbors for the next cycle
|
||||||
p->to = dest;
|
p->to = dest;
|
||||||
p->decoded.want_response = wantReplies;
|
p->decoded.want_response = wantReplies;
|
||||||
printNeighborInfo("SENDING", neighborInfo);
|
printNeighborInfo("SENDING", &neighborInfo);
|
||||||
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
service.sendToMesh(p, RX_SRC_LOCAL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user