On Linux (and possibly other platforms), when the current directory does not exist, then getcwd() always fails (and gives errno = ENOENT), meaning that the function enters an infinite loop trying to allocate larger and larger buffers until size overflows into a negative number leading to a std::bad_alloc.
|
inline char CoinFindDirSeparator() |
|
{ |
|
int size = 1000; |
|
char *buf = 0; |
|
while (true) { |
|
buf = new char[size]; |
|
if (getcwd(buf, size)) |
|
break; |
|
delete[] buf; |
|
buf = 0; |
|
size = 2 * size; |
|
} |
|
// if first char is '/' then it's unix and the dirsep is '/'. otherwise we |
|
// assume it's dos and the dirsep is '\' |
|
char dirsep = buf[0] == '/' ? '/' : '\\'; |
|
delete[] buf; |
|
return dirsep; |
|
} |
This causes Cbc and many other coin programs to crash on startup since they call CoinFindDirSeparator().
I'm not sure why the directory separator needs to be found in this way (and not just use defines to set it to backslash on Windows and forward slash everywhere else).
On Linux (and possibly other platforms), when the current directory does not exist, then
getcwd()always fails (and giveserrno = ENOENT), meaning that the function enters an infinite loop trying to allocate larger and larger buffers untilsizeoverflows into a negative number leading to astd::bad_alloc.CoinUtils/src/CoinHelperFunctions.hpp
Lines 952 to 969 in ab8cedf
This causes Cbc and many other coin programs to crash on startup since they call
CoinFindDirSeparator().I'm not sure why the directory separator needs to be found in this way (and not just use defines to set it to backslash on Windows and forward slash everywhere else).