From 42eb28852f8d95b1edacaf3406ec76b093e004dd Mon Sep 17 00:00:00 2001 From: martin Date: Sun, 8 Dec 2019 00:18:12 +0000 Subject: [PATCH] FpDebug: Win, Fix dropping last char of dll names. git-svn-id: trunk@62341 - --- components/fpdebug/fpdbgwinclasses.pas | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index fa6618a708..324158381f 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -384,19 +384,17 @@ begin // GetFinalPathNameByHandle is only available on Windows Vista / Server 2008 if assigned(_GetFinalPathNameByHandle) then begin - SetLength(u, MAX_PATH); + SetLength(u, MAX_PATH+1); len := _GetFinalPathNameByHandle(AModuleHandle, @u[1], MAX_PATH, 0); s:=''; if len > 0 then begin - SetLength(u, len - 1); - if (u<>'') and (u[length(u)]=#0) then - begin - // On some older Windows versions there's a bug in GetFinalPathNameByHandleW, - // which leads to a trailing #0. - Delete(u,length(u),1); - end; + // On some older Windows versions there's a bug in GetFinalPathNameByHandleW, + // which leads to a trailing #0. + if (u[len]=#0) then + dec(len); + SetLength(u, len); s:=UTF8Encode(u); end else begin u := '';