octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #50234] c++ file_stat with non existant crashe


From: Rik
Subject: [Octave-bug-tracker] [bug #50234] c++ file_stat with non existant crashes octave in windows
Date: Thu, 9 Feb 2017 12:56:03 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

Update of bug #50234 (project octave):

                  Status:                    None => Confirmed              

    _______________________________________________________

Follow-up Comment #10:

Confirmed.  For completeness, I booted an old Windows XP VM and ran 4.2.0 to
create a .oct file and it segfaults in the manner reported here.

Looking at the code in liboctave/system/file-ops.cc I see


    std::string
    octave::sys::file_ops::tilde_expand (const std::string& name)
    {
      if (name.find ('~') == std::string::npos)
        return name;
      else
        {
          std::string result;


I'm grasping here, but I see that name is passed in by reference, and that the
function prototype declares this const which means it is making a promise not
to change it.  However, tilde_expand just returns a std::string object.  When
a '~' is found, the function declares a temporary "std::string result" and
then proceeds to construct that string before ending with "return result;".

On the other hand, if no '~' is found then the function actually passes a
reference to a string ("return name;") rather than a string object.  It is
possible that eventually the reference is invalid but downstream functions
which called tilde_expand continue to try and use it.

As a quick test, one might try altering the return statement to


return std::string (name);





    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?50234>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]