@@ -299,7 +299,9 @@ private unsafe void SetConfigArgs(Handle config)
299
299
{
300
300
fixed ( byte * * arrayOfStringsPtrNamedArgs = args )
301
301
{
302
- Native . wasi_config_set_argv ( config , _args . Count , arrayOfStringsPtrNamedArgs ) ;
302
+ // This shouldn't ever fail - it would only return false if `ToUTF8PtrArray` creates invalid UTF8 bytes!
303
+ if ( ! Native . wasi_config_set_argv ( config , ( nuint ) _args . Count , arrayOfStringsPtrNamedArgs ) )
304
+ throw new WasmtimeException ( "Failed to encode string to UTF8" ) ;
303
305
}
304
306
}
305
307
finally
@@ -329,7 +331,9 @@ private unsafe void SetEnvironmentVariables(Handle config)
329
331
330
332
try
331
333
{
332
- Native . wasi_config_set_env ( config , _vars . Count , names , values ) ;
334
+ // This shouldn't ever fail - it would only return false if `ToUTF8PtrArray` creates invalid UTF8 bytes!
335
+ if ( ! Native . wasi_config_set_env ( config , ( nuint ) _vars . Count , names , values ) )
336
+ throw new WasmtimeException ( "Failed to encode string to UTF8" ) ;
333
337
}
334
338
finally
335
339
{
@@ -450,12 +454,14 @@ private static class Native
450
454
public static extern void wasi_config_delete ( IntPtr config ) ;
451
455
452
456
[ DllImport ( Engine . LibraryName ) ]
453
- public unsafe static extern void wasi_config_set_argv ( Handle config , int argc , byte * * argv ) ;
457
+ [ return : MarshalAs ( UnmanagedType . I1 ) ]
458
+ public unsafe static extern bool wasi_config_set_argv ( Handle config , nuint argc , byte * * argv ) ;
454
459
455
460
[ DllImport ( Engine . LibraryName ) ]
456
- public static extern unsafe void wasi_config_set_env (
461
+ [ return : MarshalAs ( UnmanagedType . I1 ) ]
462
+ public static extern unsafe bool wasi_config_set_env (
457
463
Handle config ,
458
- int envc ,
464
+ nuint envc ,
459
465
byte * [ ] names ,
460
466
byte * [ ] values
461
467
) ;
0 commit comments