[cairo] [PATCH 1/2] xlib: Don't crash when swapping a 0-sized glyph

James Cloos cloos at jhcloos.com
Thu Nov 8 16:32:21 PST 2012


AJ> malloc(0) needn't return NULL, and on glibc, doesn't.

BE> BTW, is this a recent change?  I noticed a bug because of it in harfbuzz also.

AJ> I don't believe so.  RHEL5's glibc has this property, so it's probably
AJ> been this way since at least 2006.

A quick look at the history for the malloc.c file in glibc shows
the comment fragment:

    Even a request for zero bytes (i.e., malloc(0)) returns a
    pointer to something of the minimum allocatable size.

was included in the first version of malloc/malloc.c committed to glibc
back on 1996/Dec/08.

Glibc may never have returned NULL from malloc(0).

I do not recall what libc5 did, nor what the BSDs or the commercial
unixen did back then.

-JimC
-- 
James Cloos <cloos at jhcloos.com>         OpenPGP: 1024D/ED7DAEA6


More information about the cairo mailing list