[Tarantool-patches] [PATCH 1/1] app: os.setenv() affects os.environ()

Nikita Pettik korablev at tarantool.org
Thu Feb 20 00:42:45 MSK 2020


On 06 Feb 23:47, Vladislav Shpilevoy wrote:
> os.setenv() and os.environ() are Lua API for
> 
>     extern char **environ;
>     int setenv();
> 
> The Open Group standardized access points for environment
> variables. But there is no a word about that environ never
> changes. Programs can't relay on that. For example, addition of
> a new variable may cause realloc of the whole environ array, and
> therefore change of its pointer value. That was exactly the case
> in os.environ() - it was using value of environ array remembered
> when Tarantool started.
> 
> And os.setenv() could realloc the array and turn the saved pointer
> into garbage.
> 
> Closes #4733
> ---

LGTM



More information about the Tarantool-patches mailing list