From 8f34de5c103e9e4d2c27583020f2975907b626ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 22 Aug 2022 11:16:29 +0200 Subject: Manually check values for NULL when using low-level function interface --- libbuild2/cc/functions.cxx | 12 ++++++++++++ libbuild2/function.hxx | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx index bba8fbb..94900ee 100644 --- a/libbuild2/cc/functions.cxx +++ b/libbuild2/cc/functions.cxx @@ -61,6 +61,9 @@ namespace build2 // We can assume these are present due to function's types signature. // + if (vs[0].null) + throw invalid_argument ("null value"); + names& ts_ns (vs[0].as ()); // // In a somewhat hackish way strip the outer operation to match how we @@ -137,6 +140,9 @@ namespace build2 // We can assume this is present due to function's types signature. // + if (vs[0].null) + throw invalid_argument ("null value"); + names& ts_ns (vs[0].as ()); // optional li; @@ -369,6 +375,9 @@ namespace build2 bool rel (true); if (vs.size () > 2) { + if (vs[2].null) + throw invalid_argument ("null value"); + for (const name& f: vs[2].as ()) { string s (convert (name (f))); @@ -520,6 +529,9 @@ namespace build2 // We can assume the argument is present due to function's types // signature. // + if (vs[0].null) + throw invalid_argument ("null value"); + names& r (vs[0].as ()); m->deduplicate_export_libs (*bs, vector (r.begin (), r.end ()), diff --git a/libbuild2/function.hxx b/libbuild2/function.hxx index 81ece89..323ac41 100644 --- a/libbuild2/function.hxx +++ b/libbuild2/function.hxx @@ -952,7 +952,8 @@ namespace build2 // Low-level interface that can be used to pass additional data. // - // Note that the call to this function sidesteps the thunk. + // Note that the call to this function sidesteps the thunk. One notable + // consequence of this is that the values are not checked for NULL. // template void -- cgit v1.1