Skip to content

Commit

Permalink
[mono] Copy image data with AssemblyLoadContext.LoadFromStream
Browse files Browse the repository at this point in the history
We don't actually pin the byte array, so it must be copied or it can be overwritten once we run a GC on the LOH.

Fixes dotnet/runtime#43402

Tested manually that it fixes the issue using the associated repro. This isn't really something that lends itself to a test, so that's the best I can do.
  • Loading branch information
CoffeeFlux committed Oct 19, 2020
1 parent ae5d46c commit 0cf71cd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mono/metadata/appdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -2832,7 +2832,7 @@ mono_alc_load_raw_bytes (MonoAssemblyLoadContext *alc, guint8 *assembly_data, gu
{
MonoAssembly *ass = NULL;
MonoImageOpenStatus status;
MonoImage *image = mono_image_open_from_data_internal (alc, (char*)assembly_data, raw_assembly_len, FALSE, NULL, refonly, FALSE, NULL, NULL);
MonoImage *image = mono_image_open_from_data_internal (alc, (char*)assembly_data, raw_assembly_len, TRUE, NULL, refonly, FALSE, NULL, NULL);

if (!image) {
mono_error_set_bad_image_by_name (error, "In memory assembly", "0x%p", assembly_data);
Expand Down

0 comments on commit 0cf71cd

Please sign in to comment.