]> git.lyx.org Git - features.git/commitdiff
Avoid using buffer() which might throw an exception
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 7 Apr 2017 10:04:02 +0000 (12:04 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 7 Apr 2017 10:05:21 +0000 (12:05 +0200)
Actually buffer_ is always valid on this codepath, but coverity is not
able to see that.

src/insets/InsetBibitem.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetCitation.cpp
src/insets/InsetInclude.cpp

index ae6105bb62fce88dee3faf058ab8616f73bab9ee..afc30ae37d395647c16ac4391912fb0ea43c835d 100644 (file)
@@ -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();
        }
 }
 
index 99a7d55f82fb2a1b26c471c37044f8bca44d9a6d..f417d0abc5473648151abf8124e230fb02661ec5 100644 (file)
@@ -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();
        }
 }
 
index fe752246f53460ba85c554d9113ff5db0a93c3fa..1b3c482d9b40c7330a36f045b508c55399c581d2 100644 (file)
@@ -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();
 }
 
 
index 0d67f9dbd50f0f14e0917b960027925b97223062..341115cbb323eba2bed325684c0805876f2b4bce 100644 (file)
@@ -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_;
 }