On Sat, Nov 15, 2014 at 18:42, Nicolas Bedos wrote:
> In usr.bin/locate/locate/locate.c and util.c the variable dbv is defined
> as a pointer to char * and is used to access the path to every database
> provided to locate. E.g. when running
> 
> locate -d /path/to/db1 -d /path/to/db2 -d /path/to/db3 *
> 
> *dbv     points to '/path/to/db1'
> *(dbv+1) points to '/path/to/db2'
> *(dbv+2) points to '/path/to/db3'
> 
> However dbv is initialized with the following call
> 
> dbv = malloc(sizeof(char **))
> 
> which I believe should be
> 
> dbv = malloc(sizeof(char *))
> 
> The same goes for the variable newdbv. Please find the corresponding
> diff below. No binary change on amd64 since sizeof(char **) ==
> sizeof(char *).

I think using sizeof(*dbv) would be the better idiom.

Reply via email to