commit f7ab893def4c67aef70abe4403bbc6ab312bd110
Author: Jean-Marc Lasgouttes <[email protected]>
Date:   Thu Mar 9 14:26:17 2017 +0100

    Avoid dereferencing an iterator at the end
    
    Found by coverity, could lead to a crash with badly formed kmap file.
---
 src/Trans.cpp |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/Trans.cpp b/src/Trans.cpp
index ed73c77..e2ba1ab 100644
--- a/src/Trans.cpp
+++ b/src/Trans.cpp
@@ -280,17 +280,17 @@ int Trans::load(Lexer & lex)
                                    && it->second[1] == accent_2)
                                        break;
                        }
+
+                       // could not find accent2 on a key -- this should not 
happen.
+                       if (it == end)
+                               return -1;
+
                        docstring allowed;
                        if (!lex.next())
                                return -1;
-
                        allowed = lex.getDocString();
                        LYXERR(Debug::KBMAP, "allowed: " << to_utf8(allowed));
 
-                       // FIXME Coverity
-                       // This is being flagged because we could in principle 
fail
-                       // ever to hit the break above, in which case we exit 
the loop
-                       // when it == end. Then this crashes.
                        insertException(kmod_list_[accent_1].exception_list,
                                        it->first, allowed, true, accent_2);
                }

Reply via email to