Closed Bug 796999 Opened 12 years ago Closed 12 years ago

jsalloc misinterpretes malloc(0) returning null as OOM

Categories

(Core :: JavaScript Engine, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: bjacob, Unassigned)

References

Details

Attachments

(1 file)

Attached patch jsalloc fix (deleted) — Splinter Review
malloc(size) returning null does not mean allocation failure if size == 0. Same for realloc.
Attachment #667035 - Flags: review?(wmccloskey)
Comment on attachment 667035 [details] [diff] [review] jsalloc fix Sorry for the delay. There's a bit of a problem here. If we do expect that malloc can return NULL when asked for 0 bytes, then we would have to change a lot more places than this. There are lots of places in the JS engine that call malloc and assume that NULL means failure. Is there any reason you filed this bug, Benoit? I realize that what we're doing now is wrong according to the man page. However, fixing it would be a ton of work, and I'm not aware that we actually run in any environments where malloc(0) returns NULL.
Attachment #667035 - Flags: review?(wmccloskey)
The way in which I came across this was that I was playing with a malloc wrapper that did some instrumentation, and my wrappered malloc would return NULL for size 0. Since then, I've worked around this issue by returning a dummy 1-byte block instead of NULL, so I no longer personally need this to be fixed. Sounds like a WONTFIX then.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: