Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f9014720a7de8f2f51d0f08a0d40bec3d8319654
Ticket: 694232ffffffffffffffffffffffffffffffffff
lsearch causes segmentation fault
User & Date: uring on 2003-02-27 08:23:43
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The command
    
      lsearch -start 0 {} x
    
    causes a segmentation fault.
    
    This happens in function Tcl_LsearchObjCmd().
    The given argument "-start 0" in combination
    with an empty list causes the variable "offset"
    to become -1.
    
    From snapshot 2003-02-25:
    
    2931         if (offset < 0) {
    2932             offset = 0;
    2933         } else if (offset > listc-1) {
    2934             offset = listc-1;
    2935         }
    
    I'd prefer to have line 2934 as follows:
    
    2934             offset = listc > 0 ? listc-1 : 0;
    
    Perhaps this is also worth a test in lsearch.test,
    for example:
    
    test lsearch-xx.x {combine -start 0 with empty list} {
        lsearch -start 0 {} x
    } -1
    
  4. foundin changed to: "obsolete: 8.4.1.1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "uring"
  9. subsystem changed to: "17. Commands I-L"
  10. title changed to: "lsearch causes segmentation fault"
  11. type changed to: "Bug"