From 9dbf67ecdf737eea60fb2a12348e4b7157c2f096 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 27 Jan 2020 07:12:23 +0200 Subject: Add corner case check in const.{c,cxx} array splitting --- libbuild2/cc/module.cxx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/cc/module.cxx b/libbuild2/cc/module.cxx index 5ff5639..95b42bd 100644 --- a/libbuild2/cc/module.cxx +++ b/libbuild2/cc/module.cxx @@ -79,7 +79,7 @@ namespace build2 if (rs[v].defined ()) { - load_module (rs, rs, m + ".guess", loc); + init_module (rs, rs, m + ".guess", loc); cc_loaded = true; break; } @@ -126,10 +126,14 @@ namespace build2 const strings& v (cast (*p.first)); path xc; - try { xc = path (v.front ()); } catch (const invalid_path&) {} + { + const string& s (v.empty () ? empty_string : v.front ()); + + try { xc = path (s); } catch (const invalid_path&) {} - if (xc.empty ()) - fail << "invalid path '" << v.front () << "' in " << config_x; + if (xc.empty ()) + fail << "invalid path '" << s << "' in " << config_x; + } mode.assign (++v.begin (), v.end ()); @@ -257,7 +261,7 @@ namespace build2 h.assign (c_runtime) = xi.runtime; h.assign (c_stdlib) = xi.c_stdlib; - load_module (rs, rs, "cc.core.guess", loc, false, h); + init_module (rs, rs, "cc.core.guess", loc, false, h); } else { @@ -638,7 +642,7 @@ namespace build2 if (!xi.bin_pattern.empty ()) h.assign ("config.bin.pattern") = xi.bin_pattern; - load_module (rs, rs, "cc.core.config", loc, false, h); + init_module (rs, rs, "cc.core.config", loc, false, h); } } @@ -650,8 +654,7 @@ namespace build2 // Load cc.core. Besides other things, this will load bin (core) plus // extra bin.* modules we may need. // - if (!cast_false (rs["cc.core.loaded"])) - load_module (rs, rs, "cc.core", loc); + load_module (rs, rs, "cc.core", loc); // Process, sort, and cache (in this->xlate_hdr) translatable headers. // Keep the cache NULL if unused or empty. -- cgit v1.1