Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1fccfc45e94bc403b4b606488ddd27ecb50c59fb
Ticket: 1259431fffffffffffffffffffffffffffffffff
Check for 0 byte allocation in ckalloc
User & Date: mdejong on 2005-08-15 01:03:29
Changes

  1. assignee changed to: "hobbs"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    I ran into a little problem where a bug in code to call
    ckalloc ended up trying to allocate 0 bytes. That
    crashed in the Win32 malloc when compiled with
    Mingw. I can't see any reason to allow a zero byte
    allocation, and it seems like adding a test like the
    following could not hurt. Any objections?
    
    --- generic/tclCkalloc.c        19 Jan 2003 07:21:18
    -0000      1.19
    +++ generic/tclCkalloc.c        15 Aug 2005 00:59:24 -0000
    @@ -373,6 +373,10 @@
         if (validate_memory)
             Tcl_ValidateAllMemory (file, line);
    
    +    if (size == 0) {
    +        panic("attempt to ckalloc 0 bytes, %s line
    %d", size, file, line);
    +    }
    +
         result = (struct mem_header *)
    TclpAlloc((unsigned)size +
                                   sizeof(struct
    mem_header) + HIGH_GUARD_SIZE);
         if (result == NULL) {
    
    
  4. foundin changed to: "None"
  5. priority changed to: "2"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "mdejong"
  9. subsystem changed to: "41. Memory Allocation"
  10. title changed to: "Check for 0 byte allocation in ckalloc"
  11. type changed to: "Patch"