Skip to content

Commit c32a6ce

Browse files
authored
Refactor SConscript and add file checks in iwasm.c (#3945)
1 parent aabe830 commit c32a6ce

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

core/iwasm/common/SConscript

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ cwd = GetCurrentDir()
1313

1414
src = Glob('*.c')
1515

16-
if rtconfig.ARCH == 'arm':
17-
if re.match('^cortex-m.*', rtconfig.CPU):
18-
src += ['arch/invokeNative_thumb.s']
19-
elif re.match('^cortex-a.*', rtconfig.CPU):
20-
src += ['arch/invokeNative_arm.s']
21-
elif rtconfig.ARCH == 'ia32':
22-
src += ['arch/invokeNative_ia32.s']
16+
if rtconfig.ARCH == 'arm' and re.match('^cortex-m.*', rtconfig.CPU):
17+
src += ['arch/invokeNative_thumb.s']
18+
else:
19+
src.append(f"arch/invokeNative_{rtconfig.ARCH}.s")
2320

2421
CPPPATH = [cwd, cwd + '/../include']
2522

product-mini/platforms/rt-thread/iwasm.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,21 @@ my_read_file_to_buffer(char *filename, rt_uint32_t *size)
192192
{
193193
struct stat f_stat;
194194

195+
if (!filename || !size) {
196+
rt_set_errno(-EINVAL);
197+
return RT_NULL;
198+
}
199+
200+
if (stat(filename, &f_stat) != 0) {
201+
rt_set_errno(errno);
202+
return RT_NULL;
203+
}
204+
205+
if (f_stat.st_size <= 0) {
206+
rt_set_errno(-EINVAL);
207+
return RT_NULL;
208+
}
209+
195210
rt_uint8_t *buff = rt_malloc(f_stat.st_size);
196211
*size = 0;
197212
if (!buff) {

0 commit comments

Comments
 (0)