Skip to content

Commit

Permalink
Fixed breakage due to changes introduced in bytecodealliance/wasmtime@e…
Browse files Browse the repository at this point in the history
  • Loading branch information
martindevans authored and jsturtevant committed Jun 21, 2024
1 parent 9a43806 commit c2021ee
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/WasiConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,9 @@ private unsafe void SetConfigArgs(Handle config)
{
fixed (byte** arrayOfStringsPtrNamedArgs = args)
{
Native.wasi_config_set_argv(config, _args.Count, arrayOfStringsPtrNamedArgs);
// This shouldn't ever fail - it would only return false if `ToUTF8PtrArray` creates invalid UTF8 bytes!
if (!Native.wasi_config_set_argv(config, (nuint)_args.Count, arrayOfStringsPtrNamedArgs))
throw new WasmtimeException("Failed to encode string to UTF8");
}
}
finally
Expand Down Expand Up @@ -329,7 +331,9 @@ private unsafe void SetEnvironmentVariables(Handle config)

try
{
Native.wasi_config_set_env(config, _vars.Count, names, values);
// This shouldn't ever fail - it would only return false if `ToUTF8PtrArray` creates invalid UTF8 bytes!
if (!Native.wasi_config_set_env(config, (nuint)_vars.Count, names, values))
throw new WasmtimeException("Failed to encode string to UTF8");
}
finally
{
Expand Down Expand Up @@ -450,12 +454,12 @@ private static class Native
public static extern void wasi_config_delete(IntPtr config);

[DllImport(Engine.LibraryName)]
public unsafe static extern void wasi_config_set_argv(Handle config, int argc, byte** argv);
public unsafe static extern bool wasi_config_set_argv(Handle config, nuint argc, byte** argv);

[DllImport(Engine.LibraryName)]
public static extern unsafe void wasi_config_set_env(
public static extern unsafe bool wasi_config_set_env(
Handle config,
int envc,
nuint envc,
byte*[] names,
byte*[] values
);
Expand Down

0 comments on commit c2021ee

Please sign in to comment.