Skip to content

Commit

Permalink
[mono][loader] Set status on success
Browse files Browse the repository at this point in the history
Manual backport of dotnet/runtime#80949 to mono/mono

Emebedders that call `mono_assembly_load_from_full` may observe a non-NULL return value and an uninitialized MonoImageOpenStatus, which may lead to incorrect diagnostics in code like:

```
MonoImageOpenStatus status;
MonoAssembly *assembly = mono_assembly_load_from_full (image, name, status, refonly);
if (!assembly || status != MONO_IMAGE_OK) {
   fprintf(stderr, "Failure due to: %s\n", mono_image_strerror (status));
   abort();
}
```
Which will print `Failure due to: Internal error`

Addresses dotnet/android#7658
  • Loading branch information
lambdageek committed Jan 20, 2023
1 parent 7f69cba commit b7a85f8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -3177,6 +3177,8 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname,
mono_image_fixup_vtable (image);
#endif

*status = MONO_IMAGE_OK;

mono_assembly_invoke_load_hook_internal (req->alc, ass);

MONO_PROFILER_RAISE (assembly_loaded, (ass));
Expand Down

0 comments on commit b7a85f8

Please sign in to comment.