瀏覽代碼

* some potential rangecheck errors fixed, Mantis #22933, suggested fixes
by Anton

git-svn-id: trunk@22499 -

marco 13 年之前
父節點
當前提交
5866e2435c
共有 2 個文件被更改,包括 3 次插入2 次删除
  1. 2 1
      packages/chm/src/chmfiftimain.pas
  2. 1 1
      packages/chm/src/chmreader.pas

+ 2 - 1
packages/chm/src/chmfiftimain.pas

@@ -821,7 +821,8 @@ begin
   if CopyLastWordCharCount > 0 then
   if CopyLastWordCharCount > 0 then
     Result := Copy(ALastWord, 1, CopyLastWordCharCount);
     Result := Copy(ALastWord, 1, CopyLastWordCharCount);
   SetLength(Result, (WordLength-1) + CopyLastWordCharCount);
   SetLength(Result, (WordLength-1) + CopyLastWordCharCount);
-  FStream.Read(Result[1+CopyLastWordCharCount], WordLength-1);
+  if WordLength > 1 then
+    FStream.Read(Result[1+CopyLastWordCharCount], WordLength-1);
 end;
 end;
 
 
 function TChmSearchReader.ReadIndexNodeEntry (ALastWord: String;  out AWord: String; out
 function TChmSearchReader.ReadIndexNodeEntry (ALastWord: String;  out AWord: String; out

+ 1 - 1
packages/chm/src/chmreader.pas

@@ -277,7 +277,7 @@ procedure TChmReader.ReadCommonData;
      repeat
      repeat
        Stream.Read(buf, 50);
        Stream.Read(buf, 50);
        Result := Result + buf;
        Result := Result + buf;
-     until Pos(#0, buf) > -1;
+     until IndexByte(buf, 50, 0) <> -1;
      if FixURL then
      if FixURL then
        Result := StringReplace(Result, '\', '/', [rfReplaceAll]);
        Result := StringReplace(Result, '\', '/', [rfReplaceAll]);
    end;
    end;