From 9ad2bdcecde1fd9f5696ef3cb76f6762b30c01ac Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 16 Feb 2022 23:00:02 +0100 Subject: [PATCH] + patch by Bart B: TBucketList threw access violations after Clear, resolves #39565 + test --- packages/fcl-base/src/contnrs.pp | 2 +- tests/Makefile | 2 +- tests/Makefile.fpc | 2 +- tests/test/units/contnrs/tbucketlist.pp | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 tests/test/units/contnrs/tbucketlist.pp diff --git a/packages/fcl-base/src/contnrs.pp b/packages/fcl-base/src/contnrs.pp index 80955100d4..fc562e09eb 100644 --- a/packages/fcl-base/src/contnrs.pp +++ b/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; diff --git a/tests/Makefile b/tests/Makefile index 97e4ae8f3a..64c07ec249 100644 --- a/tests/Makefile +++ b/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 diff --git a/tests/Makefile.fpc b/tests/Makefile.fpc index f763faabd4..00e0713fcf 100644 --- a/tests/Makefile.fpc +++ b/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 diff --git a/tests/test/units/contnrs/tbucketlist.pp b/tests/test/units/contnrs/tbucketlist.pp new file mode 100644 index 0000000000..87dce27922 --- /dev/null +++ b/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.