-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Description
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.
CoinUtils/src/CoinHelperFunctions.hpp
Lines 952 to 969 in ab8cedf
| 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).
Metadata
Metadata
Assignees
Labels
No labels