浏览代码

fcl-db: base: CompareBookmarks() should return 0 if one of two bookmarks is nil. Test for CompareBookmarks(nil,nil) already exists.

git-svn-id: trunk@27133 -
lacak 11 年之前
父节点
当前提交
1c12fd4268
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      packages/fcl-db/src/base/bufdataset.pas

+ 8 - 3
packages/fcl-db/src/base/bufdataset.pas

@@ -1117,7 +1117,7 @@ var
 begin
 begin
   CheckInactive;
   CheckInactive;
   For I:=0 to Length(FIndexes)-1 do
   For I:=0 to Length(FIndexes)-1 do
-    FreeAndNil(Findexes[I]);
+    FreeAndNil(FIndexes[I]);
   SetLength(FIndexes,0);
   SetLength(FIndexes,0);
   FIndexesCount:=0;
   FIndexesCount:=0;
 end;
 end;
@@ -1339,7 +1339,10 @@ end;
 
 
 function TBufIndex.CompareBookmarks(const ABookmark1, ABookmark2: PBufBookmark): boolean;
 function TBufIndex.CompareBookmarks(const ABookmark1, ABookmark2: PBufBookmark): boolean;
 begin
 begin
-  Result := (ABookmark1^.BookmarkData=ABookmark2^.BookmarkData);
+  if assigned(ABookmark1) and assigned(ABookmark2) then
+    Result := (ABookmark1^.BookmarkData=ABookmark2^.BookmarkData)
+  else
+    Result := False;
 end;
 end;
 
 
 function TBufIndex.GetRecord(ABookmark: PBufBookmark; GetMode: TGetMode): TGetResult;
 function TBufIndex.GetRecord(ABookmark: PBufBookmark; GetMode: TGetMode): TGetResult;
@@ -3008,7 +3011,9 @@ end;
 function TCustomBufDataset.CompareBookmarks(Bookmark1, Bookmark2: TBookmark
 function TCustomBufDataset.CompareBookmarks(Bookmark1, Bookmark2: TBookmark
   ): Longint;
   ): Longint;
 begin
 begin
-  if Assigned(FCurrentIndex) and FCurrentIndex.CompareBookmarks(pointer(Bookmark1),pointer(Bookmark2)) then
+  if not assigned(Bookmark1) or not assigned(Bookmark2) then
+    Result := 0
+  else if Assigned(FCurrentIndex) and FCurrentIndex.CompareBookmarks(pointer(Bookmark1),pointer(Bookmark2)) then
     Result := 0
     Result := 0
   else
   else
     Result := -1;
     Result := -1;