questions on idmap_tdb.c

Herb Lewis hlewis at panasas.com
Thu Feb 22 19:45:55 GMT 2007


Trying to understand what these functions do I was looking at
idmap_tdb_remove_mapping and have some questions. First it
seems like we have a memory leak on data.dptr. We have the
following 2 lines midway through the function

         /* Check if sid is present in database */
         data = tdb_fetch(ctx->tdb, ksid);

If I followed the code correctly, data.dptr is malloced in
the tdb_fetch function. However between these 2 lines and
the following lines there was no SAFE_FREE like follows
all the remaining calls to tdb_fetch

         /* Delete previous mappings. */

         data = tdb_fetch(ctx->tdb, ksid);

We already know data.dptr is nonzero (or we would have
skipped this code) so it seems a simple SAFE_FREE(data.dptr);
before the next fetch is required or we leak that memory.
The other option would be to just remove the tdb_fetch
for ksid as that is what the previous tdb_fetch got.
I'm not sure if there was a reason for doing the fetch
again.

Second question is we do we need to do the fetch if we are
going to be calling tdb_delete? We do this before the
delete of both ksid and kid.


More information about the samba-technical mailing list