Skip to content

Commit 481601b

Browse files
committed
Avoid concatenating empty paths
1 parent 83c8956 commit 481601b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

common/paths_posix.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const char* PathsClass::Program_Path()
139139
path = (char*)malloc(size);
140140
if (!_NSGetExecutablePath(path, &size)) {
141141
free(path);
142+
ProgramPath = ".";
142143
return ProgramPath.c_str();
143144
}
144145
}
@@ -160,12 +161,14 @@ const char* PathsClass::Program_Path()
160161
size_t size = sizeof(buffer1);
161162

162163
if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0) {
164+
ProgramPath = ".";
163165
return ProgramPath.c_str();
164166
}
165167

166168
resolved = realpath(path, buffer);
167169
#endif
168170
if (!resolved) {
171+
ProgramPath = ".";
169172
return ProgramPath.c_str();
170173
}
171174

@@ -243,7 +246,9 @@ bool PathsClass::Is_Absolute(const char* path)
243246

244247
std::string PathsClass::Concatenate_Paths(const char* path1, const char* path2)
245248
{
246-
return std::string(path1) + SEP + path2;
249+
if (path1 != NULL && *path1 != '\0')
250+
return std::string(path1) + SEP + path2;
251+
return std::string(path2);
247252
}
248253

249254
std::string PathsClass::Argv_Path(const char* cmd_arg)

0 commit comments

Comments
 (0)