File tree Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Expand file tree Collapse file tree 1 file changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -238,18 +238,23 @@ impl Module {
238238 // Forget Module (and avoid calling drop) because it has been consumed by instantiate (even if it failed).
239239 core:: mem:: forget ( self ) ;
240240 if ptr. is_null ( ) {
241- return Err ( "Invalid ptr" . into ( ) ) ;
242- }
243- let instance = unsafe { NonNull :: new_unchecked ( ptr) } ;
244- Ok ( Instance {
245- instance : instance,
246- module : Module {
247- ptr : unsafe {
248- ConstNonNull :: new_unchecked ( sys:: fizzy_get_instance_module ( instance. as_ptr ( ) ) )
241+ debug_assert ! ( err. code( ) != 0 ) ;
242+ Err ( err. error ( ) . unwrap ( ) )
243+ } else {
244+ debug_assert ! ( err. code( ) == 0 ) ;
245+ let instance = unsafe { NonNull :: new_unchecked ( ptr) } ;
246+ Ok ( Instance {
247+ instance : instance,
248+ module : Module {
249+ ptr : unsafe {
250+ ConstNonNull :: new_unchecked ( sys:: fizzy_get_instance_module (
251+ instance. as_ptr ( ) ,
252+ ) )
253+ } ,
254+ owned : false ,
249255 } ,
250- owned : false ,
251- } ,
252- } )
256+ } )
257+ }
253258 }
254259
255260 /// Returns true if the module has a start function defined.
You can’t perform that action at this time.
0 commit comments