Issue:
In src/plugins/meshtastic.c:73-89 (see cleanup routine meshtastic_cleanup), the plugin frees the MeshtasticData struct during cleanup, but never removes the corresponding entry from context->plugins_data:
static void meshtastic_cleanup(DeadlightContext *context) {
MeshtasticData *data = g_hash_table_lookup(context->plugins_data, "meshtastic");
if (!data) return;
// ... free fields ...
g_free(data);
}
If the plugin is ever reloaded or another lookup occurs, context->plugins_data still contains a dangling pointer, leading to unsafe use or double-free. Compare to most plugin management patterns, where plugin hash entries are always removed on unload/unregister.
Key code:
// src/plugins/meshtastic.c
static void meshtastic_cleanup(DeadlightContext *context) {
MeshtasticData *data = g_hash_table_lookup(context->plugins_data, "meshtastic");
if (!data) return;
...
g_free(data);
// Missing: g_hash_table_remove(context->plugins_data, "meshtastic");
}
Impact:
- Dangling pointer in context leads to UAF, double free, crash, or plugin restart bugs.
- Leaks plugin hash entry after free.
Suggested fix:
Remove the plugin data entry from context->plugins_data during cleanup:
g_hash_table_remove(context->plugins_data, "meshtastic");
This must be added before freeing the MeshtasticData struct.
Issue:
In
src/plugins/meshtastic.c:73-89(see cleanup routinemeshtastic_cleanup), the plugin frees theMeshtasticDatastruct during cleanup, but never removes the corresponding entry fromcontext->plugins_data:If the plugin is ever reloaded or another lookup occurs,
context->plugins_datastill contains a dangling pointer, leading to unsafe use or double-free. Compare to most plugin management patterns, where plugin hash entries are always removed on unload/unregister.Key code:
Impact:
Suggested fix:
Remove the plugin data entry from
context->plugins_dataduring cleanup:This must be added before freeing the
MeshtasticDatastruct.