Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not the best way to call VerLanguageName in TPJVersionInfo.GetLanguage #10

Open
delphidabbler opened this issue Nov 12, 2022 · 1 comment
Assignees
Labels
accepted bug Something isn't working

Comments

@delphidabbler
Copy link
Member

In

function TPJVersionInfo.GetLanguage: string;

VerLanguageName is called like this:

if fHaveInfo and
  (VerLanguageName(GetLanguageCode, Buf, Pred(cBufSize)) > 0) then
  Result := Buf;

However the VerLanguageName docs say that if buffer size is too small, the language name is truncated. Also the number of characters written excludes the terminating null.

In practice the buffer used is probably large enough, but still the code is not best practice.

Maybe try something like example 2 from C++ (Cpp) VerLanguageName Examples - but note that the logic needs tweaking regarding buffer sizes.

@delphidabbler delphidabbler self-assigned this Nov 12, 2022
@delphidabbler delphidabbler added bug Something isn't working accepted labels Nov 12, 2022
@delphidabbler
Copy link
Member Author

To keep c++ compatibility allocation & freeing of memory will need to use GetMemory & FreeMemory rather than GetMem & FreeMem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant