Skip to content

Commit

Permalink
Rewriter: Handle unknown write targets
Browse files Browse the repository at this point in the history
Add error checks for cases in which the write target is unknown
and ensure all error cases indeed abort the execution to avoid
internal crash.

Resolves #13502.

Signed-off-by: Eyal Itkin <[email protected]>
  • Loading branch information
eyalitki committed Nov 24, 2024
1 parent 9f3f88f commit a5cbacf
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions mesonbuild/rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,21 @@ def process_kwargs(self, cmd):
arg_node = node.args
elif cmd['function'] == 'target':
tmp = self.find_target(cmd['id'])
if tmp:
node = tmp['node']
arg_node = node.args
if not tmp:
mlog.error('Unable to find the target', mlog.bold(cmd['id']), *self.on_error())
return self.handle_error()
node = tmp['node']
arg_node = node.args
elif cmd['function'] == 'dependency':
tmp = self.find_dependency(cmd['id'])
if tmp:
node = tmp['node']
arg_node = node.args
if not tmp:
mlog.error('Unable to find the dependency', mlog.bold(cmd['id']), *self.on_error())
return self.handle_error()
node = tmp['node']
arg_node = node.args
if not node:
mlog.error('Unable to find the function node')
mlog.error('Unable to find the function node', *self.on_error())
return self.handle_error()
assert isinstance(node, FunctionNode)
assert isinstance(arg_node, ArgumentNode)
# Transform the key nodes to plain strings
Expand Down

0 comments on commit a5cbacf

Please sign in to comment.