Tcl Source Code

View Ticket
Login
Ticket UUID: 4b3b7a30821038c72de6cbb4f96aa20dd8345613
Title: tcl8.5.15/generic/tclExecute.c:7713: array index before sanity check ?
Type: Bug Version: 8.5.15
Submitter: anonymous Created on: 2014-01-30 12:41:40
Subsystem: 47. Bytecode Compiler Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2014-01-31 09:17:41
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2014-01-31 09:17:41
Description:
I just ran the static analysis tool "cppcheck" over the 
source code of tcl8.5.15

It said many things, including

[/home/dcb/rpmbuild/BUILD/tcl8.5.15/generic/tclExecute.c:7713] -> [/home/dcb/rpmbuild/BUILD/tcl8.5.15/generic/tclExecute.c:7715]: (warning) Array 'operatorStrings[34]' accessed at index 59, which is out of bounds. Otherwise condition 'opcode==99' is redundant.

Source code is

    const char *description, *operator = operatorStrings[opcode - INST_LOR];

    if (opcode == INST_EXPON) {
    operator = "**";
    }

Suggest move sanity check of opcode to before its use.
User Comments: jan.nijtmans added on 2014-01-31 09:17:41:

Fixed in core-8-5-branch [f6a2f50eb8] and trunk [0b5fb73910]