Overview
| Artifact ID: | 1fccfc45e94bc403b4b606488ddd27ecb50c59fb |
|---|---|
| Ticket: | 1259431fffffffffffffffffffffffffffffffff
Check for 0 byte allocation in ckalloc |
| User & Date: | mdejong on 2005-08-15 01:03:29 |
Changes
- assignee changed to: "hobbs"
- cmimetype changed to: "text/plain"
- 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) { - foundin changed to: "None"
- priority changed to: "2"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "mdejong"
- subsystem changed to: "41. Memory Allocation"
- title changed to: "Check for 0 byte allocation in ckalloc"
- type changed to: "Patch"