]> git.lyx.org Git - features.git/commitdiff
Fix test to make coverity happy
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 7 Mar 2017 10:48:32 +0000 (11:48 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Tue, 7 Mar 2017 10:48:32 +0000 (11:48 +0100)
It is not obvious that cur is not null iff thisSlice is not -1, but
this is what happens in the caller.

src/mathed/MathData.cpp

index 322a8e9ceba2b8378a213d0e96cbf48d332e7978..3f298afad1ff3b0559bcd3976a5184290ab3728c 100644 (file)
@@ -739,7 +739,9 @@ void MathData::collectOptionalParameters(Cursor * cur,
                        params.push_back(optarg);
 
                // place cursor in optional argument of macro
-               if (thisSlice != -1
+               // Note: The two expressions on the first line are equivalent
+               // (see caller), but making this explicit pleases coverity.
+               if (cur && thisSlice != -1
                    && thisPos >= int(pos) && thisPos <= int(right)) {
                        int paramPos = max(0, thisPos - int(pos) - 1);
                        vector<CursorSlice> x;