From: Enrico Forestieri Date: Wed, 24 Jun 2015 23:25:42 +0000 (+0200) Subject: Check whether the buffer pointer is valid before using it X-Git-Tag: 2.2.0alpha1~493 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=d275d034c056ea38db70c9f713d5df0b91103d62;p=lyx.git Check whether the buffer pointer is valid before using it --- diff --git a/src/mathed/MathMacro.cpp b/src/mathed/MathMacro.cpp index 636d059a23..78ea2bb365 100644 --- a/src/mathed/MathMacro.cpp +++ b/src/mathed/MathMacro.cpp @@ -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_; }