aboutsummaryrefslogtreecommitdiffstats
path: root/unicode
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 20:24:03 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-07-23 20:24:03 +0000
commit2d2fb7b3b8d9b14bec1b2629ba7473758c21855d (patch)
tree814f679ec5223cf23bc2029a9d6e9323ec7f9a0b /unicode
parentda016e25fd242afdf83aa47d4f24eb55ef5faf02 (diff)
downloadusdx-2d2fb7b3b8d9b14bec1b2629ba7473758c21855d.tar.gz
usdx-2d2fb7b3b8d9b14bec1b2629ba7473758c21855d.tar.xz
usdx-2d2fb7b3b8d9b14bec1b2629ba7473758c21855d.zip
reset all ref-counted fields before usage of FillChar() to avoid memory leaks
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/branches/experimental@1908 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'unicode')
-rw-r--r--unicode/src/base/UCovers.pas3
-rw-r--r--unicode/src/base/UFilesystem.pas6
2 files changed, 8 insertions, 1 deletions
diff --git a/unicode/src/base/UCovers.pas b/unicode/src/base/UCovers.pas
index 0dbe672a..6c7c9e48 100644
--- a/unicode/src/base/UCovers.pas
+++ b/unicode/src/base/UCovers.pas
@@ -385,6 +385,9 @@ begin
end
else
begin
+ // FillChar() does not decrement the ref-count of ref-counted fields
+ // -> reset Name field manually
+ Result.Name := nil;
FillChar(Result, SizeOf(TTexture), 0);
end;
except on E: Exception do
diff --git a/unicode/src/base/UFilesystem.pas b/unicode/src/base/UFilesystem.pas
index a28b1f39..d4972df5 100644
--- a/unicode/src/base/UFilesystem.pas
+++ b/unicode/src/base/UFilesystem.pas
@@ -665,7 +665,11 @@ function TFileIterator.Next(): TFileInfo;
begin
if (not fHasNext) then
begin
- FillChar(Result, SizeOf(Result), 0);
+ // Note: do not use FillChar() on records with ref-counted fields
+ Result.Time := 0;
+ Result.Size := 0;
+ Result.Attr := 0;
+ Result.Name := nil;
Exit;
end;