]> git.lyx.org Git - lyx.git/commitdiff
Check whether the buffer pointer is valid before using it
authorEnrico Forestieri <forenr@lyx.org>
Wed, 24 Jun 2015 23:25:42 +0000 (01:25 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Wed, 24 Jun 2015 23:25:42 +0000 (01:25 +0200)
src/mathed/MathMacro.cpp

index 636d059a23a25ecf0090683ee91254ac29c71332..78ea2bb3654913789464948ac5efeb8a89684fec 100644 (file)
@@ -207,7 +207,7 @@ MathMacro::MathMacro(MathMacro const & that)
                // We need to update d->macro_ by ourselves because in this case
                // MathData::metrics() is not called when selecting a math inset
                DocIterator const & pos = d->macroBackup_.pos();
-               d->macro_ = pos.buffer()->getMacro(name(), pos);
+               d->macro_ = pos.buffer() ? pos.buffer()->getMacro(name(), pos) : 0;
                if (!d->macro_)
                        d->macro_ = &d->macroBackup_;
        }
@@ -225,7 +225,7 @@ MathMacro & MathMacro::operator=(MathMacro const & that)
                // We need to update d->macro_ by ourselves because in this case
                // MathData::metrics() is not called when selecting a math inset
                DocIterator const & pos = d->macroBackup_.pos();
-               d->macro_ = pos.buffer()->getMacro(name(), pos);
+               d->macro_ = pos.buffer() ? pos.buffer()->getMacro(name(), pos) : 0;
                if (!d->macro_)
                        d->macro_ = &d->macroBackup_;
        }