Overview
| Artifact ID: | 595ab49951b1ef618c65f6d4ebb10268f870e3ac |
|---|---|
| Ticket: | 218924ffffffffffffffffffffffffffffffffff
malloc(0) == NULL on AIX is not an error |
| User & Date: | nobody on 2000-10-26 01:07:57 |
Changes
- assignee changed to: "nobody"
- cmimetype changed to: "text/plain"
- comment changed to:
OriginalBugID: 2795 Bug Version: 8.2 SubmitDate: '1999-09-16' LastModified: '1999-09-18' Severity: MED Status: Released Submitter: techsupp ChangedBy: hobbs RelatedBugIDs: 2518 OS: AIX OSVersion: 4.3.2 Machine: RS6000 FixedDate: '1999-09-18' FixedInVersion: 8.2.1 ClosedDate: '2000-10-25' Name: Nick Kisseberth Comments: Tcl_Alloc(0) should either always return NULL when asked for 0 bytes or should always return a unique pointer. It shouldn't maintain the "implementation defined" definition ANSI gives malloc(0). So for AIX it could just convert a request for 0 bytes to a request for 1 byte. I prefer Tcl_Alloc(0) to return NULL, but I suspect I'll be in the minority. ObservedBehavior: Tcl doesn't like malloc(0) returning NULL. This is valid ANSI C behavior (malloc(0) is implementation defined, must return NULL or unique pointer). Tcl_Alloc will panic because of this. DesiredBehavior: malloc(0)==NULL should be permitted Patch: *** tcl8.2.0/generic/tclCkalloc.c Tue Aug 10 11:09:45 1999 --- tcl8.2.0-AIX/generic/tclCkalloc.c Thu Sep 9 11:46:12 1999 *************** *** 799,805 **** char *result; result = TclpAlloc(size); ! if (result == NULL) panic("unable to alloc %d bytes", size); return result; } --- 799,805 ---- char *result; result = TclpAlloc(size); ! if ((result == NULL) && (size != 0)) panic("unable to alloc %d bytes", size); return result; } PatchFiles: generic/tclCkalloc.c A more complete patch in the above style is included for 8.2.1. -- 09/18/1999 hobbs - foundin changed to: "obsolete: 8.2"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "69. Other"
- title changed to: "malloc(0) == NULL on AIX is not an error"
- type changed to: "Bug"