Browse Source

+ added code section duplicate check in wasm object reader

Nikolay Nikolov 1 year ago
parent
commit
7d41f5eb92
1 changed files with 7 additions and 0 deletions
  1. 7 0
      compiler/ogwasm.pas

+ 7 - 0
compiler/ogwasm.pas

@@ -2219,6 +2219,7 @@ implementation
           TypeSectionRead: Boolean = false;
           ImportSectionRead: Boolean = false;
           FunctionSectionRead: Boolean = false;
+          CodeSectionRead: Boolean = false;
           DataCountSectionRead: Boolean = false;
 
           DataCount: uint32;
@@ -2553,6 +2554,12 @@ implementation
         function ReadCodeSection: Boolean;
           begin
             Result:=False;
+            if CodeSectionRead then
+              begin
+                InputError('Code section is duplicated');
+                exit;
+              end;
+            CodeSectionRead:=True;
           end;
 
         function ReadDataSection: Boolean;