Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 86d5c0d87b46b571e7b277a90e0467f15092060c
Ticket: 218196ffffffffffffffffffffffffffffffffff
Tcl_DbCkrealloc craches on NULL-pointers
User & Date: nobody on 2000-10-26 00:54:23
Changes

  1. assignee changed to: "nobody"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    OriginalBugID: 2384 Bug
    Version: 8.2b1
    SubmitDate: '1999-07-19'
    LastModified: '1999-07-21'
    Severity: SER
    Status: Closed
    Submitter: techsupp
    ChangedBy: redman
    OS: Other
    Machine: NA
    FixedDate: '2000-10-25'
    ClosedDate: '1999-07-21'
    
    
    Name:
    
    Martin Forssen
    
    
    
    ObservedBehavior:
    
    Tcl_DbCkrealloc crashes if the memory area to be realloced is NULL.
    
    
    
    DesiredBehavior:
    
    It should work as Tcl_Dballoc in this case (since that is what realloc
    
        does)
    
    
    
    Patch:
    
    *** generic/tclCkalloc.c        Fri Apr 16 03:46:42 1999
    
    --- ../tcl8.1/generic/tclCkalloc.c      Fri May  7 22:27:39 1999
    
    ***************
    
    *** 522,535 ****
    
      {
    
          char *new;
    
          unsigned int copySize;
    
      
    
          /*
    
           * See comment from Tcl_DbCkfree before you change the following
    
           * line.
    
           */
    
      
    
    !     struct mem_header *memp = (struct mem_header *)
    
    !           (((unsigned long) ptr) - BODY_OFFSET);
    
      
    
          copySize = size;
    
          if (copySize > (unsigned int) memp->length) {
    
    --- 522,539 ----
    
      {
    
          char *new;
    
          unsigned int copySize;
    
    +     struct mem_header *memp;
    
    + 
    
    +     if (NULL == ptr) {
    
    +       return Tcl_DbCkalloc(size, file, line);
    
    +     }
    
      
    
          /*
    
           * See comment from Tcl_DbCkfree before you change the following
    
           * line.
    
           */
    
      
    
    !     memp = (struct mem_header *) (((unsigned long) ptr) - BODY_OFFSET);
    
      
    
          copySize = size;
    
          if (copySize > (unsigned int) memp->length) {
    
    
    
    PatchFiles:
    
    generic/tclCkalloc.c
    
    
    
    
    
    Umm... why in the world would you realloc a NULL pointer?  Correct behavior. 
    -- 07/21/1999 redman
    
  4. foundin changed to: "obsolete: 8.2b1"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "nobody"
  9. subsystem changed to: "69. Other"
  10. title changed to: "Tcl_DbCkrealloc craches on NULL-pointers"
  11. type changed to: "Bug"