rlutil icon indicating copy to clipboard operation
rlutil copied to clipboard

`setConsoleTitle` strings

Open MangaD opened this issue 9 years ago • 5 comments
trafficstars

There is a problem with the setConsoleTitle function. It uses const char * as string parameter for the print function when compiling with C++. This seems to be a problem because when compiling with clang++ and with the flag -fsanitizer=memory, I just get a warning about uninitialized value at the line: RLUTIL_PRINT(true_title);

So, I'd advise to change the code of that function to:

RLUTIL_INLINE void setConsoleTitle(RLUTIL_STRING_T title) {
#if defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
#ifdef __cplusplus
    SetConsoleTitleA(title.c_str());
#else
    SetConsoleTitleA(title);
#endif
#else
    RLUTIL_PRINT(ANSI_CONSOLE_TITLE_PRE);
    RLUTIL_PRINT(title);
    RLUTIL_PRINT(ANSI_CONSOLE_TITLE_POST);
#endif // defined(_WIN32) && !defined(RLUTIL_USE_ANSI)
}

MangaD avatar Oct 05 '16 11:10 MangaD

Looks :+1: if it's not a false positive. Submit a PR.

nabijaczleweli avatar Oct 05 '16 18:10 nabijaczleweli

I just checked and I think it is a false positive, sorry.

MangaD avatar Oct 05 '16 19:10 MangaD

It did seem to be :P

nabijaczleweli avatar Oct 05 '16 19:10 nabijaczleweli

@MangaD It could be that whatever you're passing as title has uninitialized bytes or something.

refi64 avatar Oct 05 '16 20:10 refi64

@kirbyfan64 I am inclined to believe that it is related with libstdc++ not being compiled with memory sanitizer, not sure though.

MangaD avatar Oct 05 '16 20:10 MangaD