[MERGED] libosmocore[master]: fsm: talloc + copy the 'id' passed into a FSM

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Jul 10 13:21:49 UTC 2016


Harald Welte has submitted this change and it was merged.

Change subject: fsm: talloc + copy the 'id' passed into a FSM
......................................................................


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
---
M src/fsm.c
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/fsm.c b/src/fsm.c
index 6649b09..049663d 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -169,7 +169,8 @@
 	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)

-- 
To view, visit https://gerrit.osmocom.org/491
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib88a2c02c5c91f17b4ec1e9db57a06d6d66465fb
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list