unsetenv() crashes after clearenv()
Bug #380487 reported by
Timo Sirainen
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
Fix Released
|
Low
|
Unassigned |
Bug Description
Here's a test program that crashes:
#include <stdlib.h>
int main(int argc, char **argv)
{
clearenv();
unsetenv(
return 0;
}
ProblemType: Bug
Architecture: i386
Dependencies:
libgcc1 1:4.3.3-5ubuntu4
gcc-4.3-base 4.3.3-5ubuntu4
findutils 4.4.0-2ubuntu4
libc6 2.9-4ubuntu6
DistroRelease: Ubuntu 9.04
NonfreeKernelMo
Package: libc6 2.9-4ubuntu6
ProcEnviron:
LANG=en_US.UTF-8
SHELL=/bin/zsh
SourcePackage: glibc
Uname: Linux 2.6.28-11-generic i686
To post a comment you must log in.
Do you think that is actually a bug, or something that you should just not do as a programmer?
"If the application modifies environ or the pointers to which it points, the behavior of unsetenv() is undefined. The unsetenv() function shall update the list of pointers to which environ points."
Running clearenv() clearly modifies environ (it sets it to NULL), and so you should expect the behaviour of unsetenv to be undefined after running this (and perhaps even crash in the way that you see)