[2020-02] [mono][loader] Set status on success; avoid mmap on Android (#21610)
commita102a350e538ec510929912b0c05d76ee4360b2e
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Thu, 26 Jan 2023 15:18:10 +0000 (26 16:18 +0100)
committerGitHub <noreply@github.com>
Thu, 26 Jan 2023 15:18:10 +0000 (26 16:18 +0100)
treedaac613e6e3c17e5a20991ee5995522f2f35d236
parent74f85c2ac3378ff537362218c262231d62a20633
[2020-02] [mono][loader] Set status on success; avoid mmap on Android (#21610)

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`

Avoid an mmap that will fail since Android uses a custom loader and the assemblies aren't on disk

Co-authored-by: Aleksey Kliger <alklig@microsoft.com>
mono/metadata/assembly.c
mono/metadata/image.c