Check whether the buffer pointer is valid before using it

This commit is contained in:
Enrico Forestieri 2015-06-25 01:25:42 +02:00
parent fee356eb56
commit d275d034c0

View 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_;
}