From 8c3c2c17027a4e482bea2000882f4b19b428f343 Mon Sep 17 00:00:00 2001 From: lateralusX Date: Wed, 16 Mar 2022 18:01:21 +0100 Subject: [PATCH] Fix incorrect conversion from int to size_t due to PR 66552. https://github.com/dotnet/runtime/pull/66552 did incorrect switch to size_t from int in a sections that expects variable to go negative. --- src/mono/mono/metadata/assembly.c | 6 ++---- src/mono/mono/metadata/icall.c | 4 +--- src/mono/mono/metadata/w32handle.c | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/metadata/assembly.c b/src/mono/mono/metadata/assembly.c index c1dad75ea980f8..3b89baefe2e53a 100644 --- a/src/mono/mono/metadata/assembly.c +++ b/src/mono/mono/metadata/assembly.c @@ -2139,10 +2139,8 @@ mono_assembly_request_load_from (MonoImage *image, const char *fname, gchar *tmp_fn; tmp_fn = g_strdup (fname); - for (size_t i = strlen (tmp_fn) - 1; i >= 0; i--) { - if (tmp_fn [i] == '/') - tmp_fn [i] = '\\'; - } + + g_strdelimit (tmp_fn, '/', '\\'); base_dir = absolute_dir (tmp_fn); g_free (tmp_fn); diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index 8d3bb497b38648..bdb83dad31a541 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -167,9 +167,7 @@ is_generic_parameter (MonoType *type) static void mono_icall_make_platform_path (gchar *path) { - for (size_t i = strlen (path); i > 0; i--) - if (path [i-1] == '\\') - path [i-1] = '/'; + g_strdelimit (path, '\\', '/'); } static const gchar * diff --git a/src/mono/mono/metadata/w32handle.c b/src/mono/mono/metadata/w32handle.c index 927bb3c6be3bf3..6ecec42af5d79d 100644 --- a/src/mono/mono/metadata/w32handle.c +++ b/src/mono/mono/metadata/w32handle.c @@ -508,7 +508,7 @@ mono_w32handle_ops_prewait (MonoW32Handle *handle_data) static void mono_w32handle_unlock_handles (MonoW32Handle **handles_data, gsize nhandles) { - for (gsize i = nhandles - 1; i >= 0; i--) { + for (int i = ((int)nhandles - 1); i >= 0; i--) { if (!handles_data [i]) continue; mono_w32handle_unlock (handles_data [i]);