Skip to content

Commit 7e36eff

Browse files
committed
Add validation for FunctionSection
* The array is required to be the same length as the Code Section array.
1 parent 47d8578 commit 7e36eff

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

TBInit.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,15 @@ def ImportSection(self):
206206
return(True)
207207

208208
def FunctionSection(self):
209-
pass
209+
section = self.module.function_section
210+
if section is None:
211+
return(True)
212+
csection = self.module.code_section
213+
if csection is None:
214+
return(False)
215+
if len(section.type_section_index) != len(csection.func_bodies):
216+
return(False)
217+
return(True)
210218

211219
def TableSection(self):
212220
pass
@@ -261,7 +269,8 @@ def ValidateAll(self):
261269
return(False)
262270
if not self.ImportSection():
263271
return(False)
264-
self.FunctionSection()
272+
if not self.FunctionSection():
273+
return(False)
265274
self.TableSection()
266275
self.MemorySection()
267276
if not self.GlobalSection():

0 commit comments

Comments
 (0)