[metadata] Fix a possible crash when looking up a p/invoke function. (#4471)
authorVincent Povirk <madewokherd@gmail.com>
Sat, 4 Mar 2017 17:03:56 +0000 (11:03 -0600)
committerZoltan Varga <vargaz@gmail.com>
Sat, 4 Mar 2017 17:03:56 +0000 (12:03 -0500)
commita56212b5ae6fe272e3b1738a65edd90f31f27d4f
treee30c4041d15657e154c0966622d6f6400699ecfc
parentb85e7c862b17520961a7e03d83600f3efe19adfe
[metadata] Fix a possible crash when looking up a p/invoke function. (#4471)

It's possible for two threads to modify the same MonoMethodPInvoke.addr
in mono_lookup_pinvoke_call, with one thread setting it to NULL inside the
loop, and the other thread having completed the loop and expecting it to
be non-NULL.

Use an intermediate variable to prevent addr becoming non-NULL.
mono/metadata/loader.c