[dasher] Fix deleting after having traversed control nodes.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Fix deleting after having traversed control nodes.
- Date: Thu, 12 May 2011 12:06:49 +0000 (UTC)
commit 9d996a52a26f403debec245c018970572b906e7e
Author: Alan Lawrence <acl33 inf phy cam ac uk>
Date: Thu May 12 13:04:52 2011 +0100
Fix deleting after having traversed control nodes.
string::substr(start,len) allows for len to take you beyond the end of
the string - in which case, you just get back the rest of the string -
but not for start to be before the beginning.
Src/DasherCore/AlphabetManager.cpp | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/Src/DasherCore/AlphabetManager.cpp b/Src/DasherCore/AlphabetManager.cpp
index f123879..8422c23 100644
--- a/Src/DasherCore/AlphabetManager.cpp
+++ b/Src/DasherCore/AlphabetManager.cpp
@@ -567,7 +567,8 @@ void CAlphabetManager::CSymbolNode::Undo(int *pNumDeleted) {
// iff this node was actually written (i.e. not rebuilt _from_ context!)
std::string &buf(m_pMgr->strTrainfileBuffer);
std::string tr(trainText());
- if (buf.substr(buf.length()-tr.length(),tr.length())==tr) {
+ if (tr.length()<=buf.length()
+ && buf.substr(buf.length()-tr.length(),tr.length())==tr) {
buf=buf.substr(0,buf.length()-tr.length());
m_pMgr->m_pLastOutput = Parent();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]