Fix leaks, checked build support around netmodules loaded as "files"
commitf822445711c103e5aab649725a34f4e2ff73f32c
authorAndi McClure <andi.mcclure@xamarin.com>
Mon, 19 Sep 2016 21:55:08 +0000 (19 17:55 -0400)
committerAndi McClure <andi.mcclure@xamarin.com>
Mon, 19 Sep 2016 21:55:08 +0000 (19 17:55 -0400)
tree7f418240418627ecc4e8ef0536b7e377db6571de
parenta26fda4e8c791516981f70190d6f5203a678bc12
Fix leaks, checked build support around netmodules loaded as "files"

Test mcs/tests/test-418.exe was failing when running a checked build
with MONO_CHECK_MODE=metadata. I audited how images track their
modules and fixed the following issues:

1. The checked build metadata "reference audit" was following
references stored in the "modules" field, but not the "files" field. I
changed the audit code to follow both.
2. Loading a module into the "modules[]" field was causing a leak
because mono_image_addref() was being called after
mono_image_open_full(), even though mono_image_open_full itself
returns the module +1. I removed the addref.
3. Loading a module into the "files[]" field was causing a leak
because we were opening the module with mono_image_open_full and then
never attempting to close it. I modified our image close to do the
same thing to "files[]" we do to "modules[]".

In order for 1 and 3 to work, I modified MonoImages to track the size
of the "files[]" field.
mono/metadata/image.c
mono/metadata/metadata-internals.h
mono/utils/checked-build.c