diff --git a/tools/webidl_binder.py b/tools/webidl_binder.py index 9cdb6a83f57db..d7ce3acfc8c3f 100644 --- a/tools/webidl_binder.py +++ b/tools/webidl_binder.py @@ -629,7 +629,8 @@ def make_call_args(i): if non_pointer: return_prefix += '&' if copy: - pre += ' static %s temp;\n' % type_to_c(return_type, non_pointing=True) + # Avoid sharing this static temp var between threads, which could race. + pre += ' static thread_local %s temp;\n' % type_to_c(return_type, non_pointing=True) return_prefix += '(temp = ' return_postfix += ', &temp)'