Refactor SConscript and add file checks in iwasm.c (#3945)

This commit is contained in:
kk
2024-12-06 14:54:37 +08:00
committed by GitHub
parent aabe83074e
commit c32a6ceae1
2 changed files with 19 additions and 7 deletions

View File

@ -192,6 +192,21 @@ my_read_file_to_buffer(char *filename, rt_uint32_t *size)
{
struct stat f_stat;
if (!filename || !size) {
rt_set_errno(-EINVAL);
return RT_NULL;
}
if (stat(filename, &f_stat) != 0) {
rt_set_errno(errno);
return RT_NULL;
}
if (f_stat.st_size <= 0) {
rt_set_errno(-EINVAL);
return RT_NULL;
}
rt_uint8_t *buff = rt_malloc(f_stat.st_size);
*size = 0;
if (!buff) {