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

Fix dangling pointer for logging file #291

Merged
merged 1 commit into from May 16, 2020

Conversation

ma8ma
Copy link
Collaborator

@ma8ma ma8ma commented May 16, 2020

標準出力をログファイルにリダイレクトさせる処理の中で一時変数の文字列からポインターを使っている、つまりダングリングポインターになっているとcppcheckに警告されたため修正します。

cppcheckのレポート

src/main.cpp:505:24: error: Using pointer to temporary. [danglingTemporaryLifetime]
        tmp = freopen( logfile, "ab", stdout );
                       ^
src/main.cpp:504:31: note: Pointer to container is created here.
        const char *logfile = to_locale_cstr( CACHE::path_msglog() );
                              ^
src/main.cpp:505:24: note: Using pointer to temporary.
        tmp = freopen( logfile, "ab", stdout );
                       ^
src/main.cpp:507:24: error: Using pointer to temporary. [danglingTemporaryLifetime]
        tmp = freopen( logfile, "ab", stderr );
                       ^
src/main.cpp:504:31: note: Pointer to container is created here.
        const char *logfile = to_locale_cstr( CACHE::path_msglog() );
                              ^
src/main.cpp:507:24: note: Using pointer to temporary.
        tmp = freopen( logfile, "ab", stderr );
                       ^

標準出力をログファイルにリダイレクトさせる処理の中で一時変数の文字列
からポインターを使っている、つまりダングリングポインターになっていると
cppcheckに警告されたため修正します。

cppcheckのレポート
```
src/main.cpp:505:24: error: Using pointer to temporary. [danglingTemporaryLifetime]
        tmp = freopen( logfile, "ab", stdout );
                       ^
src/main.cpp:504:31: note: Pointer to container is created here.
        const char *logfile = to_locale_cstr( CACHE::path_msglog() );
                              ^
src/main.cpp:505:24: note: Using pointer to temporary.
        tmp = freopen( logfile, "ab", stdout );
                       ^
src/main.cpp:507:24: error: Using pointer to temporary. [danglingTemporaryLifetime]
        tmp = freopen( logfile, "ab", stderr );
                       ^
src/main.cpp:504:31: note: Pointer to container is created here.
        const char *logfile = to_locale_cstr( CACHE::path_msglog() );
                              ^
src/main.cpp:507:24: note: Using pointer to temporary.
        tmp = freopen( logfile, "ab", stderr );
                       ^
```
@ma8ma ma8ma added the bug バグの追跡 label May 16, 2020
@ma8ma ma8ma added this to In progress in State of JDim-v0.3.0+ May 16, 2020
@ma8ma ma8ma merged commit 231c471 into JDimproved:master May 16, 2020
State of JDim-v0.3.0+ automation moved this from In progress to Done May 16, 2020
@ma8ma ma8ma deleted the main-fix-dangling-pointer branch May 16, 2020 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug バグの追跡
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant