[MPlayer-dev-eng] [PATCH] libmenu: fill allocated memory for path variable with 0, fixes menu_keepdir

Aurelien Jacobs aurel at gnuage.org
Tue Jun 3 20:42:37 CEST 2008


Guillaume LECERF wrote:

> On Tue, Jun 3, 2008 at 7:33 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
> > Guillaume LECERF wrote:
> >
> >> On Tue, Jun 3, 2008 at 2:27 PM, Guillaume LECERF <foxcore at gmail.com> wrote:
> >> >    freepath = path;
> >> >    path[st.st_size] = '\0';
> >>
> >> Further simplifications.
> >
> > No need to memset the whole path to 0. Just setting path[st.st_size] = 0
> > should be enough, as long as it's done before the call to stat().
> 
> Setting path[st.st_size] = 0 before the call to stat() implies
> splitting the test in two

No. It implies setting path[st.st_size] = 0 before the whole test
(before the if()).

> What the problem with setting the whole path to 0 ?

It uselessly set st.st_size-1 bytes to 0.

Aurel



More information about the MPlayer-dev-eng mailing list