[PATCH 2/6] alfred: free interface parameters before assigning new
Sven Eckelmann <[email protected]> Thu, 30 Jul 2026 21:31:56 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
When an interface specific parameter is given multiple times then it is necessary to free the already allocated interface string buffer. Signed-off-by: Sven Eckelmann <[email protected]> --- main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/main.c b/main.c index 21def01..cc3bc42 100644 --- a/main.c +++ b/main.c @@ -235,12 +235,6 @@ static struct globals *alfred_init(int argc, char *argv[]) case 'm': globals->opmode = OPMODE_PRIMARY; break; - case 'i': - globals->net_iface = strdup(optarg); - break; - case 'b': - globals->mesh_iface = strdup(optarg); - break; case 'V': i = atoi(optarg); if (i < 0 || i > 255) { @@ -264,10 +258,16 @@ static struct globals *alfred_init(int argc, char *argv[]) break; case 'I': globals->clientmode = CLIENT_CHANGE_INTERFACE; + /* fall-through */ + case 'i': + free(globals->net_iface); globals->net_iface = strdup(optarg); break; case 'B': globals->clientmode = CLIENT_CHANGE_BAT_IFACE; + /* fall-through */ + case 'b': + free(globals->mesh_iface); globals->mesh_iface = strdup(optarg); break; case 'S': -- 2.47.3