@@ -75,7 +75,7 @@ libwasmtime_setup_vm (void *cookie, char *const argv[], struct libwasmtime_vm *v
7575 wasm_byte_vec_t error_message ;
7676
7777 if (vm == NULL )
78- vm = malloc ( sizeof ( struct libwasmtime_vm ) );
78+ error ( EXIT_FAILURE , 0 , "internal error: cannot setup a NULL vm" );
7979
8080 // Load needed functions
8181 WASMTIME_COMMON_SYMBOLS (cookie )
@@ -162,7 +162,7 @@ libwasmtime_setup_vm (void *cookie, char *const argv[], struct libwasmtime_vm *v
162162}
163163
164164static void
165- libwasmtime_free_vm (void * cookie , struct libwasmtime_vm * vm )
165+ libwasmtime_delete_vm (void * cookie , struct libwasmtime_vm * vm )
166166{
167167 void (* wasmtime_store_delete ) (wasmtime_store_t * store )
168168 = libwasmtime_load_symbol (cookie , "wasmtime_store_delete" );
@@ -200,22 +200,22 @@ libwasmtime_exec (void *cookie, libcrun_container_t *container arg_unused,
200200 error (EXIT_FAILURE , 0 , "error loading entrypoint" );
201201 if (fseek (file , 0L , SEEK_END ))
202202 error (EXIT_FAILURE , 0 , "error fully loading entrypoint" );
203- size_t file_size = ftell (file );
204- if (file_size == ( size_t ) -1L )
203+ long file_size = ftell (file );
204+ if (file_size == -1L )
205205 error (EXIT_FAILURE , 0 , "error getting entrypoint size" );
206- wasm_byte_vec_new_uninitialized (& wasm , file_size );
206+ wasm_byte_vec_new_uninitialized (& wasm , ( size_t ) file_size );
207207 if (fseek (file , 0L , SEEK_SET ))
208208 error (EXIT_FAILURE , 0 , "error resetting entrypoint" );
209- if (fread (wasm .data , file_size , 1 , file ) != 1 )
209+ if (fread (wasm .data , ( size_t ) file_size , 1 , file ) != 1 )
210210 error (EXIT_FAILURE , 0 , "error reading entrypoint" );
211211 fclose (file );
212212
213213 // If entrypoint contains a webassembly text format
214214 // compile it on the fly and convert to equivalent
215215 // binary format.
216- if (has_suffix (pathname , ".wat" ) > 0 )
216+ if (has_case_suffix (pathname , ".wat" ) > 0 )
217217 {
218- wasmtime_error_t * err = wasmtime_wat2wasm ((char * ) wasm .data , file_size , & wasm_bytes );
218+ wasmtime_error_t * err = wasmtime_wat2wasm ((char * ) wasm .data , ( size_t ) file_size , & wasm_bytes );
219219 if (err != NULL )
220220 {
221221 wasmtime_error_message (err , & error_message );
@@ -240,7 +240,7 @@ libwasmtime_exec (void *cookie, libcrun_container_t *container arg_unused,
240240 else
241241 error (EXIT_FAILURE , 0 , "unsupported wasm encoding detected" );
242242
243- libwasmtime_free_vm (cookie , & vm );
243+ libwasmtime_delete_vm (cookie , & vm );
244244 exit (status );
245245}
246246
0 commit comments