From 8f67d22382b88b1cb266bb393c393addbb1d881f Mon Sep 17 00:00:00 2001 From: Eduardo Correia Date: Mon, 12 Oct 2026 18:30:58 -0300 Subject: [PATCH] Give script rmdir's directory entries a full path For rmdir, TScript::CreateFileList (fltDirectories) creates a bare TRemoteFile with only its name and type: no directory list and no full file name. TWebDAVFileSystem::DeleteFile takes the path from File->FullFileName, and TRemoteFile::GetFullFileName then dereferences the null Directory. With WinSCP 6.5.7 a script doing mkdir /work/gone rmdir /work/gone over WebDAV fails with "Invalid access to memory" in TRemoteFileList::GetFullDirectory (from TWebDAVFileSystem::FilePath, TTerminal::DoDeleteFile, TScript::RmDirProc). The entry now carries its absolute path, resolved as TTerminal::DoDeleteFile resolves the same name. Protocols that use the file name (SFTP, SCP, FTP) are unaffected; WebDAV now deletes the directory. --- source/core/Script.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/core/Script.cpp b/source/core/Script.cpp index 724bec861..d1814a6ba 100644 --- a/source/core/Script.cpp +++ b/source/core/Script.cpp @@ -587,6 +587,8 @@ TStrings * __fastcall TScript::CreateFileList(TScriptProcParams * Parameters, in { TRemoteFile * File = new TRemoteFile(); File->FileName = FileName; + // There is no listing to resolve the path from + File->FullFileName = FTerminal->AbsolutePath(FileName, true); File->Type = FILETYPE_DIRECTORY; Result->AddObject(FileName, File); }