In file_dlg::file_names method there is a bug that causes crash under VC8 compiler.
The problem occurs on line "it_start = it_end + 1;"
Internally STL processes the '+' operator as '+=', therefore when the it_end == files_.end() it crashes.
Just s simple patch will solve the problem:
if (it_end != files_.end())
it_start = it_end + 1;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is that you cannot move iterator beyong the end() of the collection. There should be always a check before incrementing it.
(Well, at least there is no bounds checking in STL 8)... Just wondering how it works in VC7...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In file_dlg::file_names method there is a bug that causes crash under VC8 compiler.
The problem occurs on line "it_start = it_end + 1;"
Internally STL processes the '+' operator as '+=', therefore when the it_end == files_.end() it crashes.
Just s simple patch will solve the problem:
if (it_end != files_.end())
it_start = it_end + 1;
Thanks. Will update!
I can say something like this:
it_start = it_end; ++it_start.
Best,
John
The problem is that you cannot move iterator beyong the end() of the collection. There should be always a check before incrementing it.
(Well, at least there is no bounds checking in STL 8)... Just wondering how it works in VC7...
Basically, I would say that it's a bug on the STL.
Here's how the code looks right now:
for (iter it_end = files_.begin(); it_end != files_.end();) {
it_end = std::find(it_start, files_.end(), '\0');
defs::string s(it_start, it_end);
if (!s.empty() && !first_file.empty())
vec.push_back(first_file + '\\' + s); // multi-select: first file is directory
else if (!s.empty())
first_file = s;
// it_start = it_end + 1;
// many thanks to dremon !!!
// https://sourceforge.net/forum/message.php?msg_id=3405198
it_start = it_end; ++it_start;
}
So, if you're inside the 'for', it_end is clearly less than files_.end().
Thus, "it_start = it_end + 1;" should be completely ok.
Or, am I missing something?
Best,
John
Yes, I was missing something :)
Gee, man -- I can't believe I didn't see it from the beginning -- the "it_end = std::find(it_start, files_.end(), '\0');" line.
Yup, you were right from the beginning.
Best,
John