[fpc-pascal] [ISSUE] FCL-Web: TUploadedFile causing memory leak?
Michael Van Canneyt
michael at freepascal.org
Mon Jul 15 09:40:39 CEST 2013
On Sun, 14 Jul 2013, silvioprog wrote:
> Hello,
> Please see:
>
> http://bugs.freepascal.org/view.php?id=24746
There are several things VERY wrong with your test program.
First:
VFile.Read(VBuf, VBufLen); // reading only the first 1024 bytes ...
Overrides the VBUf address.
It must be
VFile.Read(VBuf[0], VBufLen); // reading only the first 1024 bytes ...
Secondly,
VFile.Free; // free stream allowing to delete uploaded file, but, it causes
Frees the stream, but does not set the Stream property of TUploadedFile to nil.
When TUploadedFile is freed, it frees again the memory stream, causing an access violation.
I do not understand how your program could ever function.
I got access violations all over the place trying to run it.
Anyway, after fixing the 2 above issues it ran smootly.
Now, I suspect that the DeleteTempUploadedFiles does not work because Windows has the files locked when you attempt to delete them, so I changed TUploadedFile.DeleteTempUploadedFile
so it first frees the stream if there is one.
(cannot test that under Linux, where the demo runs fine)
Michael.
More information about the fpc-pascal
mailing list