Leaderboard
Popular Content
Showing content with the highest reputation on 07/03/20 in Posts
-
FreeAndNil 10.4 vs 10.3.1 and Pointers
Sherlock replied to Sherlock's topic in RTL and Delphi Object Pascal
I don't hate them, I just don't need them. 😉 -
Close enough.
-
OK, I got it now! START /WAIT does the trick. Now it makes sense what you @Mahdi Safsafi and @Anders Melander are talking about. To recap: - running GUI application (no matter if it actually shows any GUI) - starting it in batch file, all commands are within same 'virtual' command window, so %ERRORLEVEL% will find correct ExitCode from project - starting it manually in cmd with just project.exe starts new 'virtual' command window and next manual command echo %ERRORLEVEL% will not find correct ExitCode from project, because it is not running in same command window. To fix this, we should use START /WAIT project.exe command. - running console application: - all works OK in all situation (with or wihtout batch file), because console application always runs in same command window as next commands, like echo %ERRORLEVEL% Right?
-
When calling a console application from CMD, current CMD becomes a window for that application. And CMD will wait for that application to terminate in order to execute the next instruction. With that being said, CMD can have the correct ERRORLEVEL. But when calling a non-console application, CMD runs the application and returns immediately without waiting the application to be terminated. So it can't have a correct ERRORLEVEL. using START /WAIT app.exe will create a new CMD2(console) that runs app.exe inside CMD2. and current CMD will wait CMD2 to terminate. So it would have the correct ERRORLEVEL.
-
You are just repeating what you wrote in your OP. It's really very simple. Just abandon your assumption that commands entered on the command prompt are treated the same way as commands in a batch file; They are not. The behavior you are observing is as expected. For console applications both cmd and bat will start the process, wait for its termination and set errorlevel to the process exit code. For GUI applications bat will do the same as for console applications, but cmd will start the process without waiting for it to terminate. The value of errorlevel is irrelevant. All this has nothing to do with Delphi BTW.
-
One more memory leak and FastMM4
Remy Lebeau replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
As you noted, that code is not allocating memory correctly. GetMem() operates on bytes, but s.Length is expressed in characters, not bytes, and SizeOf(Char) is 2 bytes in D2009+, so you need to double the allocation, otherwise you will have a buffer overflow on StrPCopy(), corrupting surrounding memory, which can lead to all kinds of problems, including leaks of other things that were allocated dynamically, if you corrupt the pointers to them: var pc: PChar; s: String; begin s := 'Hello, world!'; GetMem(pc, (s.Length + 1) * SizeOf(Char)); try StrPCopy(pc, s); finally FreeMem(pc); end; end; Alternatively, use StrAlloc() instead: var pc: PChar; s: String; begin s := 'Hello, world!'; pc := StrAlloc(s.Length + 1); try StrPCopy(pc, s); finally StrDispose(pc); end; end; In either case, I would not use GetMem() or StrAlloc() at all, I would use a dynamic array instead: Var pc: array of Char; // or TArray<Char> s: String; begin s := 'Hello, world!'; SetLength(pc, s.Length + 1); StrPCopy(PChar(pc), s); end; Now, with that said, you claim you are seeing "leaks" when you use StrPCopy(pc, s + s) and StrPCopy(pc, s + s + s + s +s). Well, those are both buffer overflows, since you are allocating only enough memory for 1 string. It is likely that one of the pointers you are corrupting may be the one used by 'pc' or 's' itself! You will have to use the debugger to verify that. Check the values of the pointers before and after calling StrPCopy(), and see if they changed. Or even put Data Breakpoints on the pointers and see if the breakpoints are getting triggered. -
Devart SecureBridge Got Support for Latest Rad Studio 10.4 Sydney
Jordan Sanders posted a topic in Delphi Third-Party
Devart, a recognized vendor of world-class data connectivity solutions for various data connection technologies and frameworks, released SecureBridge v9.3 with support for RAD Studio 10.4 Sydney. Other notable updates include the support for Lazarus 2.0.8 and the macOS 64-bit target platform in Lazarus. The list of new and improved features inсludes: Support for the newest RAD Studio 10.4 Sydney; Support for the latest Lazarus version 2.0.8; Support for the Socks4 and Socks5 network protocols for routing traffic to a server through a firewall; A new class, TScPKCS12Processor, to support importing certificates and private keys from keystore files in the PKCS #12 format; Support for SSH dynamic port forwarding in TScSSHChannel; Support for the Signed Certificate Timestamp (SCT) certificate extension. SecureBridge offers components that can be used as clients and servers for SSH, SFTP, SSL, FTPS, HTTP/HTTPS, WebSocket, and SignalR protocols to protect data flow over an untrusted network. It is also compatible with data access components to prevent data interception and theft. To learn more about the current release, please visit https://blog.devart.com/securebridge-with-support-for-rad-studio-10-4.html About Devart Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects. For additional information about Devart, visit https://www.devart.com/ -
One more memory leak and FastMM4
Remy Lebeau replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
The stack trace you showed is complaining that the character data for the UnicodeString returned by TJSONString.Value is what is being leaked. That UnicodeString is assigned to your private FToken variable. Which means the TBetFairApi object that is holding that UnicodeString is not freeing that UnicodeString properly. Either because itself is being leaked as well, or you have a bug elsewhere in your code that is overwriting the UnicodeString's internal pointer to the allocated character data. Either way, this is happening after TBetFairApi.GetToken() has exited, so the problem is not in TBetFairApi.GetToken() itself. The leak report is merely showing you the call stack leading up to the memory allocation that leaked, not the call stack leading up to the leak itself. That was a typo in my example. I meant to free only the TJSONValue that ParseJSONValue() returns, not the TJSONValue of the 'token' field. I have corrected that mistake in my earlier example. -
One more memory leak and FastMM4
David Heffernan replied to Alberto Paganini's topic in RTL and Delphi Object Pascal
Dude, just make a minimal example and debug that. Post it here if you want. Really good discipline to learn how to make that minimal example. -
Sending Email via GMail Using OAuth 2.0 via Indy
Geoffrey Smith replied to Ugochukwu Mmaduekwe's topic in Indy
I have updated the demo. The demo now includes saving and loading refresh tokens, as well as checking for expired access_tokens and refreshing them with the refresh_token. Have a look at https://github.com/geoffsmith82/GmailAuthSMTP/ Geoffrey -
Sending Email via GMail Using OAuth 2.0 via Indy
Geoffrey Smith replied to Ugochukwu Mmaduekwe's topic in Indy
I've updated my project so it now not only sends messages via gmail... but it can send hotmail.com/live.com/outlook.com emails. GmailAuthSMTP supports the XOAUTH2 and OAUTHBEARER authentication types and so could probably support other mail providers if they use those standards as well. https://github.com/geoffsmith82/GmailAuthSMTP/ -
A bug in the TStringGrid implementation in Delphi 10.4. https://quality.embarcadero.com/browse/RSP-28821