Skip to content

Commit

Permalink
Fix appctx property lengths including the null terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
kg committed Apr 24, 2024
1 parent ce53f9c commit 0844d15
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/mono/mono/metadata/appdomain.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,9 +880,10 @@ mono_runtime_install_appctx_properties (void)
for (int i = 0; i < n_appctx_props; ++i) {
glong num_chars;
combined_keys [i] = g_utf8_to_utf16 (appctx_keys [i], -1, NULL, &num_chars, NULL);
combined_key_lengths [i] = GLONG_TO_UINT32 (num_chars);
// HACK: items_written from g_utf8_to_utf16 includes the null terminator unless you pass an explicit length.
combined_key_lengths [i] = GLONG_TO_UINT32 (num_chars ? num_chars - 1 : 0);
combined_values [i] = g_utf8_to_utf16 (appctx_values [i], -1, NULL, &num_chars, NULL);
combined_value_lengths [i] = GLONG_TO_UINT32 (num_chars);
combined_value_lengths [i] = GLONG_TO_UINT32 (num_chars ? num_chars - 1 : 0);
}

runtimeconfig_json_read_props (
Expand Down

0 comments on commit 0844d15

Please sign in to comment.