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

[config] Changed cwdPath logic to not leak memory #1781

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

Peguen
Copy link
Contributor

@Peguen Peguen commented Nov 5, 2024

Description

If calling the getcwd function with a nullptr, memory gets leaked. This can be avoided by passing a buffer. The buffer size is dependend on the systems maximum size for paths.

@Peguen Peguen requested a review from KerstinKeller November 5, 2024 09:38
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

#endif
#ifdef ECAL_OS_LINUX
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <limits.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead [modernize-deprecated-headers]

Suggested change
#include <limits.h>
#include <climits>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest to follow that suggestion 😄


setPathSep(cwd_path);
return cwd_path;
char temp[MAXIMUM_PATH_LENGTH];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: do not declare C-style arrays, use std::array<> instead [cppcoreguidelines-avoid-c-arrays]

    char temp[MAXIMUM_PATH_LENGTH];  
    ^

Copy link
Contributor

@KerstinKeller KerstinKeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to make sense 😄

@KerstinKeller KerstinKeller added the cherry-pick-to-NONE Don't cherry-pick these changes label Nov 8, 2024
@KerstinKeller KerstinKeller merged commit 0a47c89 into master Nov 8, 2024
19 of 22 checks passed
@Peguen Peguen deleted the hotfix/mem_leak_cwd branch November 27, 2024 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-to-NONE Don't cherry-pick these changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants