@@ -299,7 +299,9 @@ private unsafe void SetConfigArgs(Handle config)
299299 {
300300 fixed ( byte * * arrayOfStringsPtrNamedArgs = args )
301301 {
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" ) ;
303305 }
304306 }
305307 finally
@@ -329,7 +331,9 @@ private unsafe void SetEnvironmentVariables(Handle config)
329331
330332 try
331333 {
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" ) ;
333337 }
334338 finally
335339 {
@@ -450,12 +454,12 @@ private static class Native
450454 public static extern void wasi_config_delete ( IntPtr config ) ;
451455
452456 [ DllImport ( Engine . LibraryName ) ]
453- public unsafe static extern void wasi_config_set_argv ( Handle config , int argc , byte * * argv ) ;
457+ public unsafe static extern bool wasi_config_set_argv ( Handle config , nuint argc , byte * * argv ) ;
454458
455459 [ DllImport ( Engine . LibraryName ) ]
456- public static extern unsafe void wasi_config_set_env (
460+ public static extern unsafe bool wasi_config_set_env (
457461 Handle config ,
458- int envc ,
462+ nuint envc ,
459463 byte * [ ] names ,
460464 byte * [ ] values
461465 ) ;
0 commit comments