Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ensure to not expose the last_query cache

Ensure we do not give out a reference to the internal argument cache of
the compilation database. Instead explicitly copy the internal cache.
The problem with just giving out a reference is that later passes may
modify the argument list. This does not only add unrelated content to
the internal cache, but it also may lead to random crashes in case we
use the argument list from different threads.
  • Loading branch information...
commit 058a1741b1c7273285a6f65dbc15b0872d2df837 1 parent 3a2f0a5
@tobig tobig authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 plugin/libclang.py
View
7 plugin/libclang.py
@@ -296,7 +296,12 @@ def getCompilationDBParams(fileName):
continue
args.append(arg)
getCompilationDBParams.last_query = { 'args': args, 'cwd': cwd }
- return getCompilationDBParams.last_query
+
+ # Do not directly return last_query, but make sure we return a deep copy.
+ # Otherwise users of that result may accidently change it and store invalid
+ # values in our cache.
+ query = getCompilationDBParams.last_query
+ return { 'args': list(query['args']), 'cwd': query['cwd']}
getCompilationDBParams.last_query = { 'args': [], 'cwd': None }
Please sign in to comment.
Something went wrong with that request. Please try again.