While running purify on lyx, I find plenty of uninitialized memory
read coming from lyxstring constructor
  lyxstring::lyxstring(value_type const * s, size_type n)

The problem is that the constructor uses at some place min(n, strlen(s)) 
although s may not be null terminated. I propose to rewrite the
constructor as follows:

lyxstring::lyxstring(value_type const * s, size_type n)
{
        Assert(s && n < npos); // STD!
        static Srep empty_rep(0, "");
        if (*s && n) { // s is not empty string and n > 0
                size_type l = 0;
                while (l < n && s[l])
                        l++;
                rep = new Srep(l, s);
                // rep = new Srep(min(strlen(s),n), s);
        } else {
                ++empty_rep.ref;
                rep = &empty_rep;
        }
}


Lars, before changing this somewhat sensitive code, could you comment
on what is the right fix?

JMarc

Reply via email to