Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 07/03/20 in all areas

  1. I don't hate them, I just don't need them. 😉
  2. Anders Melander

    Problem with ExitCode

    Close enough.
  3. Mike Torrettinni

    Problem with ExitCode

    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?
  4. Mahdi Safsafi

    Problem with ExitCode

    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.
  5. Anders Melander

    Problem with ExitCode

    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.
  6. Remy Lebeau

    One more memory leak and FastMM4

    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.
  7. 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/
  8. Remy Lebeau

    One more memory leak and FastMM4

    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.
  9. David Heffernan

    One more memory leak and FastMM4

    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.
  10. Geoffrey Smith

    Sending Email via GMail Using OAuth 2.0 via 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
  11. Geoffrey Smith

    Sending Email via GMail Using OAuth 2.0 via 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/
  12. dummzeuch

    Strange text effect

    A bug in the TStringGrid implementation in Delphi 10.4. https://quality.embarcadero.com/browse/RSP-28821
×