From f3239113db910962a4ccac2f93d689a86450264f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 10 Jul 2016 15:11:45 +0200 Subject: fsm: talloc + copy the 'id' passed into a FSM The 'id' is used to generate the human-readable name of the FSM. However, when the FSM creates slave FSMs later, the caller-passed "ID" mgiht long be gone again (e.g. it was on stack memory). So let's copy the 'id' string to a chunk of dynamically-allocated memory at time of FSM start to ensure we have it later when creating child FSMs. Change-Id: Ib88a2c02c5c91f17b4ec1e9db57a06d6d66465fb --- src/fsm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fsm.c b/src/fsm.c index 6649b091..049663d7 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -169,7 +169,8 @@ struct osmo_fsm_inst *osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void fi->log_level = log_level; fi->timer.data = fi; fi->timer.cb = fsm_tmr_cb; - fi->id = id; + if (id) + fi->id = talloc_strdup(fi, id); if (!fsm_log_addr) { if (id) -- cgit v1.2.3