[MPlayer-dev-eng] running a program with a keystroke - passing playing filename to it

Elias Gabriel Amaral da Silva tolkiendili at gmail.com
Tue Dec 21 14:23:30 CET 2010


2010/12/21 Clément Bœsch <ubitux at gmail.com>:
> On Tue, Dec 21, 2010 at 09:33:40AM -0300, Elias Gabriel Amaral da Silva wrote:
> [...]
>> Also uau suggested that instead of keeping hard-coded environment
>> variables (since the list of them could grow), one should expand
>> mplayer variables on run parameter, like osd_show_property_text does.
>
> Sounds like the correct thing to do indeed.

Thank you for your input.

It seems that implementing it that way would not be too complicated.
It would just amount to a call to m_properties_expand_string and I'm
done..

But this interface, expanding things that looks like shell parameters
but aren't, seems a bit confusing.

>> diff --git a/command.c b/command.c
>> index b95b750..2f8d189 100644
>> --- a/command.c
>> +++ b/command.c
>> @@ -3375,7 +3375,24 @@ int run_command(MPContext *mpctx, mp_cmd_t *cmd)
>>          case MP_CMD_RUN:
>>  #ifndef __MINGW32__
>>              if (!fork()) {
>> +                char* media_len = malloc(32);
>> +                char* media_pos = malloc(32);
>> +
>> +                if(mp_property_do("length", M_PROPERTY_TO_STRING,
>> +                                  &media_len, mpctx) <= 0 ||
>> +                   mp_property_do("time_pos", M_PROPERTY_TO_STRING,
>> +                                  &media_pos, mpctx) <= 0) {
>> +
>
> Huh? Isn't the allocations useless? If it is needed, are you sure there is
> some kind of snprintf with a size limit to 32? And where do you free them?

Yes, I had no idea on a proper size. The code as such might have some
kind of buffer overrun.

It seems that I writing just char* media_len; with no allocation
works. I'm attaching a new patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-command.c-setting-environment-variables-on-run-comma.patch
Type: text/x-patch
Size: 2539 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20101221/23daf7eb/attachment.bin>


More information about the MPlayer-dev-eng mailing list