Browse Source

Avoid out of range access to instab array

Pierre Muller 3 months ago
parent
commit
f579f6dba5
1 changed files with 6 additions and 1 deletions
  1. 6 1
      compiler/x86/aasmcpu.pas

+ 6 - 1
compiler/x86/aasmcpu.pas

@@ -909,6 +909,8 @@ implementation
                       exit;
                       exit;
                   end;
                   end;
                 inc(i);
                 inc(i);
+                if i>high(instab) then
+                  exit;
                 insentry:=@instab[i];
                 insentry:=@instab[i];
               end;
               end;
           end;
           end;
@@ -1997,7 +1999,10 @@ implementation
                result:=true;
                result:=true;
                exit;
                exit;
              end;
              end;
-           inc(insentry);
+           inc(i);
+           if i>high(instab) then
+             exit;
+           insentry:=@instab[i];
          end;
          end;
         Message1(asmw_e_invalid_opcode_and_operands,GetString);
         Message1(asmw_e_invalid_opcode_and_operands,GetString);
         { No instruction found, set insentry to nil and inssize to -1 }
         { No instruction found, set insentry to nil and inssize to -1 }