diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-04-11 14:39:31 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-04-11 14:39:31 +0200 |
commit | d6e9703edbd28508882fab3ce698617d036abfdd (patch) | |
tree | ef544027338453bdd783996bca7856ed65ccc1e9 /libbuild2/config | |
parent | 87a7253a3bd82b59063172f3799b0a5587e7b2a5 (diff) |
Diagnose empty paths in config.config.{load,save}
GitHub issue #372.
Diffstat (limited to 'libbuild2/config')
-rw-r--r-- | libbuild2/config/init.cxx | 4 | ||||
-rw-r--r-- | libbuild2/config/operation.cxx | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/libbuild2/config/init.cxx b/libbuild2/config/init.cxx index d1a57b9..2f134c4 100644 --- a/libbuild2/config/init.cxx +++ b/libbuild2/config/init.cxx @@ -487,7 +487,9 @@ namespace build2 const string& s (f.string ()); - if (s[0] != '~') + if (s.empty ()) + fail << "empty path in config.config.load"; + else if (s[0] != '~') load_config_file (f, l); else if (s == "~host" || s == "~host-no-warnings" || s == "~build2" || s == "~build2-no-warnings") diff --git a/libbuild2/config/operation.cxx b/libbuild2/config/operation.cxx index 5983e4b..150bf1a 100644 --- a/libbuild2/config/operation.cxx +++ b/libbuild2/config/operation.cxx @@ -759,6 +759,11 @@ namespace build2 lookup l (rs[*c_s]); if (l && (l.belongs (rs) || l.belongs (ctx.global_scope))) { + const path& f (cast<path> (l)); + + if (f.empty ()) + fail << "empty path in " << *c_s; + // While writing the complete configuration seems like a natural // default, there might be a desire to take inheritance into // account (if, say, we are exporting at multiple levels). One can @@ -766,8 +771,7 @@ namespace build2 // still want to support this mode somehow in the future (it seems // like an override of config.config.persist should do the trick). // - save_config ( - rs, cast<path> (l), false /* inherit */, mod, projects); + save_config (rs, f, false /* inherit */, mod, projects); } } } |