From 7fbc419525c76512b3fdc72987f636bec90554de Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 26 Jun 2020 08:16:51 +0200 Subject: Fix race in library metadata protocol Specifically, we need to check whether the prerequisite_member is ad hoc before checking whether it is NULL because ad hoc ones are blanked out (set to NULL) during execute. --- libbuild2/cc/common.cxx | 5 +++-- libbuild2/cc/windows-rpath.cxx | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'libbuild2/cc') diff --git a/libbuild2/cc/common.cxx b/libbuild2/cc/common.cxx index 8150cfa..ce80e3f 100644 --- a/libbuild2/cc/common.cxx +++ b/libbuild2/cc/common.cxx @@ -240,9 +240,10 @@ namespace build2 for (const prerequisite_target& pt: l.prerequisite_targets[a]) { // Note: adhoc prerequisites are not part of the library meta- - // information protocol. + // information protocol (and we should check for adhoc first to + // avoid races). // - if (pt == nullptr || pt.adhoc) + if (pt.adhoc || pt == nullptr) continue; bool la; diff --git a/libbuild2/cc/windows-rpath.cxx b/libbuild2/cc/windows-rpath.cxx index f1d4749..eddb9c4 100644 --- a/libbuild2/cc/windows-rpath.cxx +++ b/libbuild2/cc/windows-rpath.cxx @@ -109,7 +109,7 @@ namespace build2 for (const prerequisite_target& pt: t.prerequisite_targets[a]) { - if (pt == nullptr || pt.adhoc) + if (pt.adhoc || pt == nullptr) continue; bool la; @@ -204,7 +204,7 @@ namespace build2 for (const prerequisite_target& pt: t.prerequisite_targets[a]) { - if (pt == nullptr || pt.adhoc) + if (pt.adhoc || pt == nullptr) continue; bool la; -- cgit v1.1