Tk Library Source Code

View Ticket
Login
Ticket UUID: f4b93930510520d92e1fa58b38c7eac72b8432a4
Title: Error on ctext when C comments enabled
Type: Patch Version: 0.7
Submitter: geballin Created on: 2020-04-22 20:02:13
Subsystem: tklib :: ctext Assigned To: nobody
Priority: 5 Medium Severity: Critical
Status: Open Last Modified: 2020-04-22 20:02:13
Resolution: None Closed By: nobody
    Closed on:
Description:
In ctext, sometimes we can get the error when using ctext::enableComments :
    can't read "length": no such variable
    can't read "length": no such variable
        while executing
    "$win index "$index + $length chars""
        (procedure "ctext::comments" line 26)
        invoked from within
    "ctext::comments .client.right.text 1"
        ("after" script)

This is because the length variable is not verified if defined before use.

Patch file for ctext.tcl file is :
--- ctext.tcl	2013-03-26 02:46:44.000000000 +0100
+++ ctext.tcl.new	2020-04-22 22:42:55.163217426 +0200
@@ -670,6 +670,10 @@
     while 1 {
 	set index [$win search -count length -regexp $commentRE $startIndex end]
 
+	if {![info exists length]} {
+	    break
+        }
+
 	if {$index == ""} {
 	    break
 	}