浏览代码

* fixed potential range errors in indexbyte/indexword

git-svn-id: trunk@33567 -
Jonas Maebe 9 年之前
父节点
当前提交
162c4ef6f3
共有 1 个文件被更改,包括 10 次插入10 次删除
  1. 10 10
      rtl/jvm/jvm.inc

+ 10 - 10
rtl/jvm/jvm.inc

@@ -188,8 +188,8 @@ function  IndexByte(const buf: array of jbyte;len:SizeInt;b:jbyte):SizeInt;
     i: SizeInt;
     i: SizeInt;
   begin
   begin
     if len<0 then
     if len<0 then
-      len:=high(buf);
-    for i:=0 to len do
+      len:=high(buf)+1;
+    for i:=0 to len-1 do
       if buf[i]=b then
       if buf[i]=b then
         exit(i);
         exit(i);
     IndexByte:=-1;
     IndexByte:=-1;
@@ -201,8 +201,8 @@ var
   i: SizeInt;
   i: SizeInt;
 begin
 begin
   if len<0 then
   if len<0 then
-    len:=high(buf);
-  for i:=0 to len do
+    len:=high(buf)+1;
+  for i:=0 to len-1 do
     if jbyte(buf[i])=b then
     if jbyte(buf[i])=b then
       exit(i);
       exit(i);
   IndexByte:=-1;
   IndexByte:=-1;
@@ -227,8 +227,8 @@ function  IndexWord(const buf: array of jshort;len:SizeInt;b:jshort):SizeInt;
     i: SizeInt;
     i: SizeInt;
   begin
   begin
     if len<0 then
     if len<0 then
-      len:=high(buf);
-    for i:=0 to len do
+      len:=high(buf)+1;
+    for i:=0 to len-1 do
       if buf[i]=b then
       if buf[i]=b then
         exit(i);
         exit(i);
     IndexWord:=-1;
     IndexWord:=-1;
@@ -240,8 +240,8 @@ function  IndexWord(const buf: array of jchar;len:SizeInt;b:jchar):SizeInt;
     i: SizeInt;
     i: SizeInt;
   begin
   begin
     if len<0 then
     if len<0 then
-      len:=high(buf);
-    for i:=0 to len do
+      len:=high(buf)+1;
+    for i:=0 to len-1 do
       if buf[i]=b then
       if buf[i]=b then
         exit(i);
         exit(i);
     IndexWord:=-1;
     IndexWord:=-1;
@@ -254,8 +254,8 @@ function  IndexWord(const buf: array of jchar;len:SizeInt;b:jshort):SizeInt;
   begin
   begin
     c:=jchar(b);
     c:=jchar(b);
     if len<0 then
     if len<0 then
-      len:=high(buf);
-    for i:=0 to len do
+      len:=high(buf)+1;
+    for i:=0 to len-1 do
       if buf[i]=c then
       if buf[i]=c then
         exit(i);
         exit(i);
     IndexWord:=-1;
     IndexWord:=-1;