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

Guillaume LECERF foxcore at gmail.com
Tue Jun 3 21:00:38 CEST 2008


On Tue, Jun 3, 2008 at 8:42 PM, Aurelien Jacobs <aurel at gnuage.org> wrote:
>> 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()).

OK, I got it now. The st struct is used twice, once for
MENU_KEEP_PATH, and once for the path it contains.
So I thought that the right st.size was the 2nd one. Then I realized
that the size of MENU_KEEP_PATH and the length of the path is contains
are actually equals.

>> What the problem with setting the whole path to 0 ?
>
> It uselessly set st.st_size-1 bytes to 0.

I'm ok with you for a speed-critical section of the code, but in this
case, it _should_ have been good enough.

BTW patches attached (fix + cosmetic).

-- 
Guillaume LECERF
GeeXboX developer - www.geexbox.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-menu_keepdir-01.diff
Type: text/x-patch
Size: 631 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080603/4fdf65d2/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fix-menu_keepdir-remove-braces-01.diff
Type: text/x-patch
Size: 538 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20080603/4fdf65d2/attachment-0001.bin>


More information about the MPlayer-dev-eng mailing list