Browse Source

cfg_get_by_name() returns an error instead of the incorrect value
if a fix-up function is defined

Miklos Tirpak 17 years ago
parent
commit
9a037e7d7e
1 changed files with 7 additions and 0 deletions
  1. 7 0
      cfg/cfg_ctx.c

+ 7 - 0
cfg/cfg_ctx.c

@@ -731,6 +731,13 @@ int cfg_get_by_name(cfg_ctx_t *ctx, str *group_name, str *var_name,
 	if (cfg_lookup_var(group_name, var_name, &group, &var))
 		return -1;
 
+	if (var->def->on_change_cb) {
+		/* The variable cannot be retrieved, because the fixup
+		function may have changed it, and it is better to return
+		an error than an incorrect value */
+		return -1;
+	}
+
 	/* use the module's handle to access the variable
 	It means that the variable is read from the local config
 	after forking */