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

Log safty #23

Open
DrYaling opened this issue Dec 15, 2022 · 1 comment
Open

Log safty #23

DrYaling opened this issue Dec 15, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@DrYaling
Copy link

void Log(const char* s, int32 len)
{
    // TODO: Can we get rid of that allocation?
    FString LogString = FString(len, UTF8_TO_TCHAR(s));
    UE_LOG(LogTemp, Warning, TEXT("%s"), *LogString);
}

I'm not sure whether UTF8_TO_TCHAR(s) will lead to undefined behavior. This MACRO will call utf8 conversion of option ENullTerminatedString::Yes, but rust native string end with no \0
Maybe use

 (TCHAR*)FUTF8ToTCHAR((const ANSICHAR*)str, (int32)len).Get()

should be safer?

@MaikKlein
Copy link
Owner

Good catch, we probably should pass the length there directly, otherwise it will call strlen which is not great.

@MaikKlein MaikKlein added the bug Something isn't working label Dec 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants