file_dlg with VC8 compiler

  • dp

    dp - 2005-10-30

    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;

    • John Torjo

      John Torjo - 2005-11-07

      Thanks. Will update!

      I can say something like this:

      it_start = it_end; ++it_start.


      • dp

        dp - 2005-11-07

        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...

        • John Torjo

          John Torjo - 2005-11-15

          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 !!!
                  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?


          • John Torjo

            John Torjo - 2005-11-15

            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.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks