real_main: Use setenv() instead of putenv()
commit6310e40d47b2c4ba4af7c9098c72f8069386b90b
authorCarlos R. Mafra <crmafra@gmail.com>
Mon, 17 Aug 2009 20:03:28 +0000 (17 22:03 +0200)
committerCarlos R. Mafra <crmafra@gmail.com>
Mon, 17 Aug 2009 20:19:58 +0000 (17 22:19 +0200)
treeefb87aa4666fa5f13685bac6abc5d3771d429868
parent7a84127a275c2f72dbc162830b4fbb366aa48b6d
real_main: Use setenv() instead of putenv()

When investigating possible memory leaks with 'valgrind' I noticed
this leak report:

 602 bytes in 13 blocks are definitely lost in loss record 77 of 128
    at 0x4C2362E: malloc (vg_replace_malloc.c:207)
    by 0x4576ED: wmalloc (memory.c:88)
    by 0x45B4F7: wstrconcat (string.c:214)
    by 0x426FC2: main (main.c:608)

which happens here,

    str = wstrconcat("WMAKER_BIN_NAME=", argv[0]);
    putenv(str);

There is a comment further below (in another context)

/* return of wstrconcat should not be free-ed! read putenv man page */

so this leak report is probably a false positive anyway. However,
https://www.securecoding.cert.org/confluence/display/seccode/POS34-C.+Do+not+call+putenv%28%29+with+a+pointer+to+an+automatic+variable+as+the+argument
has some nice discussion about putenv() and after reading it I decided to
use setenv() instead, making 'valgrind' happy along the way. It also
makes the code a bit simpler, avoiding a call to wstrconcat().

I also changed the name of another variable called 'str' to 'pos', just
in case.
src/main.c