From b7159f4a1a8901bfc4f1ecc7cff29b789c2101e9 Mon Sep 17 00:00:00 2001 From: fxxf Date: Thu, 16 Jun 2022 20:54:58 +0300 Subject: [PATCH] fix crash when passing invalid inputs as build_target dependencies The `add_deps` function did not behave correctly when a specified dependency is not an instance of `dependencies.Dependency`. Reorder the logic flow to perform this validation first. Fixes #10468 --- mesonbuild/build.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 233d95353..ea9b2c286 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1343,12 +1343,6 @@ class BuildTarget(Target): if dep in self.added_deps: continue - dep_d_features = dep.d_features - - for feature in ('versions', 'import_dirs'): - if feature in dep_d_features: - self.d_features[feature].extend(dep_d_features[feature]) - if isinstance(dep, dependencies.InternalDependency): # Those parts that are internal. self.process_sourcelist(dep.sources) @@ -1387,6 +1381,13 @@ You probably should put it in link_with instead.''') 'either an external dependency (returned by find_library() or ' 'dependency()) or an internal dependency (returned by ' 'declare_dependency()).') + + dep_d_features = dep.d_features + + for feature in ('versions', 'import_dirs'): + if feature in dep_d_features: + self.d_features[feature].extend(dep_d_features[feature]) + self.added_deps.add(dep) def get_external_deps(self) -> T.List[dependencies.Dependency]: