[PATCH] Autodetection of esd can trash environment variables, leading to a crash of the application using libao
The ao_plugin_text() function in src/plugins/esd/ao_esd.c adds an environment variable using putenv(). The putenv() function uses the reference that is passed to it. This is fine, until ao_shutdown() is called and the ao esd plugin is unloaded, at which point the reference passed to putenv() becomes invalid and future calls to getenv() may cause a crash.
I'm experiencing this in Gaim CVS, where we've moved our call to ao_shutdown() to be earlier in our shutdown process, and we have calls to gettext afterwards which call getenv() which causes a crash.
The best solution for this is to call unsetenv() to unset the ESD_NO_SPAWN environment variable. I think you could also go back to using setenv, which looks like it makes a copy of the data passed to it (although it seems to be less portable). However, it's probably better to not set that environment variable in the parent's process.