Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_DbCkrealloc craches on NULL-pointers

Closed / Fixed218196ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 00:54:23
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
welch Closed ticket [218196ffff]. [History diff]2000-10-26 08:16:56
dgp Ticket [218196ffff]: 3 changes [History diff]2001-04-18 21:36:04
Log in (anonymous is fine) to add a comment.