From 61cafeb4d263c279dc43a0475fc1e16a5de38dea Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 7 Apr 2017 12:04:02 +0200 Subject: [PATCH] Avoid using buffer() which might throw an exception Actually buffer_ is always valid on this codepath, but coverity is not able to see that. --- src/insets/InsetBibitem.cpp | 8 ++++---- src/insets/InsetBibtex.cpp | 11 +++++------ src/insets/InsetCitation.cpp | 8 ++++---- src/insets/InsetInclude.cpp | 8 ++++---- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index ae6105bb62..afc30ae37d 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -69,10 +69,10 @@ InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p) InsetBibitem::~InsetBibitem() { if (isBufferLoaded()) { - /* Coverity believes that this may throw an exception, but - * actually this code path is not taken when buffer_ == 0 */ - LATTEST(buffer_); - buffer().invalidateBibinfoCache(); + /* We do not use buffer() because Coverity believes that this + * may throw an exception. Actually this code path is not + * taken when buffer_ == 0 */ + buffer_->invalidateBibinfoCache(); } } diff --git a/src/insets/InsetBibtex.cpp b/src/insets/InsetBibtex.cpp index 99a7d55f82..f417d0abc5 100644 --- a/src/insets/InsetBibtex.cpp +++ b/src/insets/InsetBibtex.cpp @@ -68,12 +68,11 @@ InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p) InsetBibtex::~InsetBibtex() { if (isBufferLoaded()) { - /* Coverity believes that this may throw an exception, but - * actually this code path is not taken when buffer_ == 0 */ - // coverity[fun_call_w_exception] - buffer().invalidateBibfileCache(); - // coverity[fun_call_w_exception] - buffer().removeBiblioTempFiles(); + /* We do not use buffer() because Coverity believes that this + * may throw an exception. Actually this code path is not + * taken when buffer_ == 0 */ + buffer_-> invalidateBibfileCache(); + buffer_->removeBiblioTempFiles(); } } diff --git a/src/insets/InsetCitation.cpp b/src/insets/InsetCitation.cpp index fe752246f5..1b3c482d9b 100644 --- a/src/insets/InsetCitation.cpp +++ b/src/insets/InsetCitation.cpp @@ -55,10 +55,10 @@ InsetCitation::InsetCitation(Buffer * buf, InsetCommandParams const & p) InsetCitation::~InsetCitation() { if (isBufferLoaded()) - /* Coverity believes that this may throw an exception, but - * actually this code path is not taken when buffer_ == 0 */ - // coverity[fun_call_w_exception] - buffer().removeBiblioTempFiles(); + /* We do not use buffer() because Coverity believes that this + * may throw an exception. Actually this code path is not + * taken when buffer_ == 0 */ + buffer_->removeBiblioTempFiles(); } diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 0d67f9dbd5..341115cbb3 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -198,10 +198,10 @@ InsetInclude::InsetInclude(InsetInclude const & other) InsetInclude::~InsetInclude() { if (isBufferLoaded()) - /* Coverity believes that this may throw an exception, but - * actually this code path is not taken when buffer_ == 0 */ - // coverity[exn_spec_violation] - buffer().invalidateBibfileCache(); + /* We do not use buffer() because Coverity believes that this + * may throw an exception. Actually this code path is not + * taken when buffer_ == 0 */ + buffer_->invalidateBibfileCache(); delete label_; } -- 2.39.2