Mike Hommey 4725fcb648 Bug 1271574 - Purposefully leak the XUL_APP_FILE string passed to putenv. r=bsmedberg
Before bug 552864, the string was created with PR_smprintf, and
PR_SetEnv'ed (which, under the hood, just calls putenv). PR_smprintf was
allocating the string on the heap. Now, it's allocated on the stack, and
still putenv'ed.

putenv kind of takes ownership of the strings it's being passed, so
stack allocated strings are dangerous to use. It looks like we've been
fairly lucky that it worked, presumably because compilers would keep the
stack frame with the variable, but that's not guaranteed to happen, and
in some case, doesn't.

So we strdup the string and purposefully leak it instead, which matches
what happened before bug 552864, and is the only "sane" way to use
putenv.

--HG--
extra : rebase_source : e39349f90f5346b591e20696c0c3c7fdb26c3cfb
2016-06-02 08:44:16 +09:00
..