[PATCH] samdb: Add NULL checks

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Mar 13 09:54:59 MDT 2015


On Fri, Mar 13, 2015 at 04:25:59PM +0100, David Disseldorp wrote:
> On Fri, 13 Mar 2015 11:12:31 +0100, Volker Lendecke wrote:
> 
> >  	private_dir = talloc_strdup(data, secrets_ldb);
> > +	if (private_dir == NULL) {
> > +		return ldb_oom(ldb);
> > +	}
> >  	p = strrchr(private_dir, '/');
> >  	if (p) {
> >  		*p = '\0';
> >  	} else {
> >  		private_dir = talloc_strdup(data, ".");
> > +		if (private_dir == NULL) {
> > +			return ldb_oom(ldb);
> > +		}
> 
> Please free @data before returning in both cases. The talloc_asprintf()

I'm not sure it's the right thing to do. I followed the
sample code a few lines above:

        secrets_ldb = (const char *)ldb_get_opaque(ldb, "ldb_url");
        if (!secrets_ldb) {
                return ldb_operr(ldb);
        }

There "data" also already exists but is not released.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list