Przeglądaj źródła

fixing the parameter of the per-child process callback, it did not
alway contain the variable name properly

Miklos Tirpak 17 lat temu
rodzic
commit
d8bad60674
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      cfg/cfg_ctx.c

+ 5 - 1
cfg/cfg_ctx.c

@@ -304,7 +304,11 @@ int cfg_set_now(cfg_ctx_t *ctx, str *group_name, str *var_name,
 	}
 	}
 
 
 	if (var->def->on_set_child_cb) {
 	if (var->def->on_set_child_cb) {
-		child_cb = cfg_child_cb_new(var_name,
+		/* get the name of the variable from the internal struct,
+		because var_name may be freed before the callback needs it */
+		s.s = var->def->name;
+		s.len = var->name_len;
+		child_cb = cfg_child_cb_new(&s,
 					var->def->on_set_child_cb);
 					var->def->on_set_child_cb);
 		if (!child_cb) {
 		if (!child_cb) {
 			LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");
 			LOG(L_ERR, "ERROR: cfg_set_now(): not enough shm memory\n");