Browse Source

+ check the code entries count in the wasm object reader

Nikolay Nikolov 1 year ago
parent
commit
4b179ce4fa
1 changed files with 5 additions and 0 deletions
  1. 5 0
      compiler/ogwasm.pas

+ 5 - 0
compiler/ogwasm.pas

@@ -3091,6 +3091,11 @@ implementation
                 InputError('Error reading the code entries cound from the code section');
                 exit;
               end;
+            if CodeEntriesCount <> (Length(FuncTypes) - FuncTypeImportsCount) then
+              begin
+                InputError('Code segment count in the code section does not match the function definition count in the function section');
+                exit;
+              end;
             SetLength(CodeSegments,CodeEntriesCount);
             for i:=0 to CodeEntriesCount-1 do
               with CodeSegments[i] do