[FFmpeg-devel] [PATCH] parseutils: replace setenv() by putenv().

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Apr 27 17:44:08 CEST 2012


On Fri, Apr 27, 2012 at 05:34:21PM +0200, Nicolas George wrote:
> Le nonidi 9 floréal, an CCXX, Reimar Döffinger a écrit :
> > It probably doesn't matter much in reality, but the reason for that is
> > that the string is directly integrated into the environment and that
> > consists of modifiable strings.
> > So it isn't really correct to pass a string constant I believe.
> 
> I see. Do you want me to change it to use av_strdup or is it ok to assume
> that the libc functions will not try to alter the content of the string?

Using dup will probably leak memory, at the very least on BSD
(unless you free it, but then you end up with an invalid pointer
in the environment).
The only reasonable alternative might be a static non-const array,
but that comes with other issues.
Note that the issue is not so much whether the libc will try
to alter the string which is unlikely, it might be a user space
application that tries to change it - since it is only in the test code
that probably doesn't really matter though.
But I guess a
static char tzstr[] = "TZ...";
probably is safest.


More information about the ffmpeg-devel mailing list