Skip to content

Commit

Permalink
[loader] Set status on success (#80951)
Browse files Browse the repository at this point in the history
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

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
  • Loading branch information
github-actions[bot] and lambdageek authored Feb 8, 2023
1 parent 8502110 commit c50038c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/metadata/assembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -2025,6 +2025,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 c50038c

Please sign in to comment.