File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 2222#include < rcutils/process.h>
2323#include < rcutils/types/string_array.h>
2424
25+ #include < limits.h>
2526#include < string>
2627
2728#include " gtest/gtest.h"
@@ -89,7 +90,11 @@ class LoggingTest : public AllocatorTest
8990 throw std::runtime_error (" Failed to glob for log files" );
9091 }
9192
92- char raw_line[2048 ];
93+ #ifdef _WIN32
94+ char raw_line[MAX_PATH];
95+ #else
96+ char raw_line[PATH_MAX];
97+ #endif
9398 char * ret = fgets (raw_line, sizeof (raw_line), fp);
9499 pclose (fp);
95100 if (nullptr == ret) {
Original file line number Diff line number Diff line change 1919#include < rcutils/error_handling.h>
2020#include < rcutils/logging.h>
2121
22+ #include < limits.h>
2223#include < fstream>
2324#include < string>
2425
@@ -64,24 +65,22 @@ class RestoreEnvVar
6465// TODO(cottsay): Remove when ros2/rcpputils#63 is resolved
6566static fs::path current_path ()
6667{
67- char * cwd;
6868#ifdef _WIN32
6969#ifdef UNICODE
7070#error "rcpputils::fs does not support Unicode paths"
7171#endif
72- cwd = _getcwd (NULL , 0 );
72+ char cwd[MAX_PATH];
73+ if (nullptr == _getcwd (cwd, MAX_PATH)) {
7374#else
74- cwd = getcwd (NULL , 0 );
75+ char cwd[PATH_MAX];
76+ if (nullptr == getcwd (cwd, PATH_MAX)) {
7577#endif
76- if (nullptr == cwd) {
7778 std::error_code ec{errno, std::system_category ()};
7879 errno = 0 ;
7980 throw std::system_error{ec, " cannot get current working directory" };
8081 }
8182
82- std::string ret (cwd);
83- free (cwd);
84- return fs::path (ret);
83+ return fs::path (cwd);
8584}
8685
8786TEST_F (LoggingTest, init_invalid)
You can’t perform that action at this time.
0 commit comments