[ldns-users] malloc error handling

Alexander E. Patrakov patrakov at gmail.com
Mon Apr 5 11:03:58 UTC 2010


In general, ldns tries to check the return value of malloc. However,
sometimes such checks are forgotten. E.g., in this piece of code, a
failure of ldns_rdf_new() will lead to the leak of rdf_data:

ldns_native2rdf_int32(ldns_rdf_type type, uint32_t value)
        uint32_t *rdf_data = LDNS_XMALLOC(uint32_t, 1);
        if (!rdf_data) {
                return NULL;
        ldns_write_uint32(rdf_data, value);
        return ldns_rdf_new(type, LDNS_RDF_SIZE_DOUBLEWORD, rdf_data);

Is this a bug?

Alexander E. Patrakov

More information about the ldns-users mailing list