Use setenv in qputenv if possible, since it won't leak
authorThiago Macieira <thiago.macieira@intel.com>
Fri, 7 Sep 2012 14:13:36 +0000 (16:13 +0200)
committerQt by Nokia <qt-info@nokia.com>
Fri, 7 Sep 2012 16:41:22 +0000 (18:41 +0200)
commit19fc1de9fc5fda0db672231785bea3f3ae098fca
tree77a8286189f2b2c6efd50506079f5028fdc3a5b0
parentecbaa69d71992e6447df7b40b0c4e0dc6f255654
Use setenv in qputenv if possible, since it won't leak

putenv(3) is evil: SUSv2 requires that the pointer passed to it be added
to the environment and that modifying the contents of that pointer later
will also cause the environment to change. That means we needed to
strdup before calling it and that memory was never freed.

This shows up all the time in valgrind's leak check.

Instead, let's use the 4.3BSD & POSIX.1-2001 setenv(3) function, which
does copy. That means there are either no leaks or, if there are,
they're not our fault.

Change-Id: I4576f91cc718b6b3cae790c4f2854c4976dded37
Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
src/corelib/global/qglobal.cpp