Forráskód Böngészése

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

Miklos Tirpak 17 éve
szülő
commit
9a037e7d7e
1 módosított fájl, 7 hozzáadás és 0 törlés
  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))
 	if (cfg_lookup_var(group_name, var_name, &group, &var))
 		return -1;
 		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
 	/* use the module's handle to access the variable
 	It means that the variable is read from the local config
 	It means that the variable is read from the local config
 	after forking */
 	after forking */