Browse Source

+ check for duplicated WASM_SEGMENT_INFO subsections

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

+ 9 - 0
compiler/ogwasm.pas

@@ -2233,6 +2233,9 @@ implementation
 
 
           function ReadLinkingSection: Boolean;
           function ReadLinkingSection: Boolean;
 
 
+            var
+              SegmentInfoSectionRead: Boolean = false;
+
             function ReadSegmentInfo: Boolean;
             function ReadSegmentInfo: Boolean;
               var
               var
                 SegmentCount, SegAlignment, SegFlags: uint32;
                 SegmentCount, SegAlignment, SegFlags: uint32;
@@ -2240,6 +2243,12 @@ implementation
                 SegName: ansistring;
                 SegName: ansistring;
               begin
               begin
                 Result:=False;
                 Result:=False;
+                if SegmentInfoSectionRead then
+                  begin
+                    InputError('The WASM_SEGMENT_INFO section is duplicated');
+                    exit;
+                  end;
+                SegmentInfoSectionRead:=True;
                 if not ReadUleb32(SegmentCount) then
                 if not ReadUleb32(SegmentCount) then
                   begin
                   begin
                     InputError('Error reading the segment count from the WASM_SEGMENT_INFO subsection of the ''linking'' section');
                     InputError('Error reading the segment count from the WASM_SEGMENT_INFO subsection of the ''linking'' section');