mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Fix SIGSEGV when substituting sequence with shorter one
This commit is contained in:
parent
ab443a8ecf
commit
81183ae7d1
2 changed files with 9 additions and 1 deletions
|
@ -1393,7 +1393,7 @@ void Task::substitute (
|
||||||
int skew = 0;
|
int skew = 0;
|
||||||
for (unsigned int i = 0; i < start.size () && !done; ++i)
|
for (unsigned int i = 0; i < start.size () && !done; ++i)
|
||||||
{
|
{
|
||||||
description.replace (start[i + skew], end[i] - start[i], to);
|
description.replace (start[i] + skew, end[i] - start[i], to);
|
||||||
skew += to.length () - (end[i] - start[i]);
|
skew += to.length () - (end[i] - start[i]);
|
||||||
++changes;
|
++changes;
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,14 @@ class TestSubstitutions(TestCase):
|
||||||
code, out, err = self.t("_get 1.description")
|
code, out, err = self.t("_get 1.description")
|
||||||
self.assertEqual("aaa BbB\n", out)
|
self.assertEqual("aaa BbB\n", out)
|
||||||
|
|
||||||
|
def test_substitution_long_with_short(self):
|
||||||
|
"""Verify substitution of a sequence with a shorter sequence."""
|
||||||
|
self.t("add aaaaBaaaa")
|
||||||
|
self.t("1 modify /aaaa/c/g")
|
||||||
|
code, out, err = self.t("_get 1.description")
|
||||||
|
self.assertEqual("cBc\n", out)
|
||||||
|
|
||||||
|
|
||||||
class TestBug441(TestCase):
|
class TestBug441(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.t = Task()
|
self.t = Task()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue