]> git.lyx.org Git - features.git/commitdiff
Annotate destructors to please coverity
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 27 Mar 2017 14:18:14 +0000 (16:18 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 31 Mar 2017 08:58:43 +0000 (10:58 +0200)
Coverity flags this code as not handling exception that may happen in buffer().

My own analysis is that this can never happen because isBufferValid()
does check whether buffer_ is null.

Any insght appreciated. The commit should be expeanded to more cases, actually.

src/insets/Inset.h
src/insets/InsetBibitem.cpp
src/insets/InsetBibtex.cpp
src/insets/InsetInclude.cpp

index 5d7f27f89ff4655732856731197f85874fa61f16..3d93904fdb3b07ffc9a7f4b28f030f2597f79d0f 100644 (file)
@@ -112,8 +112,8 @@ public:
        /// reset associated Buffer to null value
        virtual void resetBuffer();
        /// retrieve associated Buffer
-       virtual Buffer & buffer();
-       virtual Buffer const & buffer() const;
+       Buffer & buffer();
+       Buffer const & buffer() const;
        /// Returns true if buffer_ actually points to a Buffer that has
        /// been loaded into LyX and is still open. Note that this will
        /// always return false for cloned Buffers. If you want to allow
index 18a261a3e0290d969730728a2e20683f41e1a3e1..1c8bc786db6ddb9130151fb96dcbbfe7c8ef988f 100644 (file)
@@ -68,6 +68,9 @@ InsetBibitem::InsetBibitem(Buffer * buf, InsetCommandParams const & p)
 InsetBibitem::~InsetBibitem()
 {
        if (isBufferLoaded())
+               /* Coverity believs that this may throw an exception, but
+                * actually this code path is not taken when buffer_ == 0 */
+               // coverity[exn_spec_violation]
                buffer().invalidateBibinfoCache();
 }
 
index ef794814aea8fb3bb4c8e671d04cc1a6b5e311bf..63ae8657f0bf9371f3fb1505f5e3564e6e052006 100644 (file)
@@ -68,7 +68,11 @@ InsetBibtex::InsetBibtex(Buffer * buf, InsetCommandParams const & p)
 InsetBibtex::~InsetBibtex()
 {
        if (isBufferLoaded()) {
+               /* Coverity believs that this may throw an exception, but
+                * actually this code path is not taken when buffer_ == 0 */
+               // coverity[exn_spec_violation]
                buffer().invalidateBibfileCache();
+               // coverity[exn_spec_violation]
                buffer().removeBiblioTempFiles();
        }
 }
index b2eca715054a7f1f82ab01740796e1f90ee42b13..1c80afffd7ba204289339f8bc4cc0d1864f52c1e 100644 (file)
@@ -198,6 +198,9 @@ InsetInclude::InsetInclude(InsetInclude const & other)
 InsetInclude::~InsetInclude()
 {
        if (isBufferLoaded())
+               /* Coverity believs that this may throw an exception, but
+                * actually this code path is not taken when buffer_ == 0 */
+               // coverity[exn_spec_violation]
                buffer().invalidateBibfileCache();
        delete label_;
 }