Browse Source

+ patch by Bart B: TBucketList threw access violations after Clear, resolves #39565
+ test

florian 3 years ago
parent
commit
9ad2bdcecd

+ 1 - 1
packages/fcl-base/src/contnrs.pp

@@ -2579,6 +2579,7 @@ end;
 destructor TCustomBucketList.Destroy;
 begin
   Clear;
+  SetLength(FBuckets,0);
   inherited Destroy;
 end;
 
@@ -2593,7 +2594,6 @@ begin
     for J:=B.Count-1 downto 0 do
       DeleteItem(I,J);
     end;
-  SetLength(FBuckets,0);
 end;
 
 Function TCustomBucketList.Add(AItem, AData: Pointer): Pointer;

+ 1 - 1
tests/Makefile

@@ -2486,7 +2486,7 @@ export LOG:=$(TEST_OUTPUTDIR)/log
 endif
 LOGFILES=$(TEST_OUTPUTDIR)/log $(TEST_OUTPUTDIR)/longlog $(TEST_OUTPUTDIR)/faillist
 LOGEXT=.testlog .tbslog .tbflog .webtbslog .webtbflog
-TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable
+TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable contnrs
 TESTDIRECTDIRS=
 TESTSUBDIRS=cg cg/variants cg/cdecl cpu16 cpu16/i8086 library opt $(addprefix units/,$(TESTUNITDIRS))
 TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2 fcl-net

+ 1 - 1
tests/Makefile.fpc

@@ -159,7 +159,7 @@ LOGFILES=$(TEST_OUTPUTDIR)/log $(TEST_OUTPUTDIR)/longlog $(TEST_OUTPUTDIR)/faill
 LOGEXT=.testlog .tbslog .tbflog .webtbslog .webtbflog
 
 # Subdirs available in the test subdir
-TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable
+TESTUNITDIRS=system dos crt objects strings sysutils math sharemem strutils matrix lineinfo ucomplex fpwidestring cpu fmtbcd windows classes character dateutil fpcunit softfpu variants sortbase sortalgs linux unixutil types nullable contnrs
 TESTDIRECTDIRS=
 TESTSUBDIRS=cg cg/variants cg/cdecl cpu16 cpu16/i8086 library opt $(addprefix units/,$(TESTUNITDIRS))
 TESTPACKAGESDIRS=win-base webtbs hash fcl-registry fcl-process zlib fcl-db fcl-xml cocoaint bzip2 fcl-net

+ 8 - 0
tests/test/units/contnrs/tbucketlist.pp

@@ -0,0 +1,8 @@
+program Project1;
+uses contnrs;
+var b:TBucketList;
+begin
+  b:=TBucketList.Create();
+  b.Clear();
+  b.Add(nil,nil);
+end.