Fix crash if tags/marks contains invalid entry (#1614)
* Fix crash if tags file contains invalid entry * Fix crash if marks file contains invalid entry
This commit is contained in:
1 parent
8ee8592b91
commit
055ce47224
1 file changed
+11
-8
@@ -1868,9 +1868,12 @@ func (nav *nav) readMarks() error {
|
|||||||
|
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
toks := strings.SplitN(scanner.Text(), ":", 2)
|
mark, path, found := strings.Cut(scanner.Text(), ":")
|
||||||
if _, ok := nav.marks[toks[0]]; !ok {
|
if !found {
|
||||||
nav.marks[toks[0]] = toks[1]
|
return fmt.Errorf("invalid marks file entry: %s", scanner.Text())
|
||||||
|
}
|
||||||
|
if _, ok := nav.marks[mark]; !ok {
|
||||||
|
nav.marks[mark] = path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1923,12 +1926,12 @@ func (nav *nav) readTags() error {
|
|||||||
|
|
||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
text := scanner.Text()
|
path, tag, found := strings.Cut(scanner.Text(), ":")
|
||||||
ind := strings.LastIndex(text, ":")
|
if !found {
|
||||||
path := text[0:ind]
|
return fmt.Errorf("invalid tags file entry: %s", scanner.Text())
|
||||||
mark := text[ind+1:]
|
}
|
||||||
if _, ok := nav.tags[path]; !ok {
|
if _, ok := nav.tags[path]; !ok {
|
||||||
nav.tags[path] = mark
|
nav.tags[path] = tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user