diff options
author | Daniel Kolesa <q66@chimera-linux.org> | 2023-06-07 15:06:00 +0000 |
---|---|---|
committer | Jilles Tjoelker <jilles@FreeBSD.org> | 2023-06-08 21:01:43 +0000 |
commit | 2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b (patch) | |
tree | e91b8fed3d78e902dc9c7a31a2fb8e933170a11b /bin | |
parent | 1320520ba488386251a7d02bd90842e031931133 (diff) | |
download | src-2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b.tar.gz src-2178e8c27aada86ce679d90b8d6cd61dc3bc7f6b.zip |
sh: make smark a static variable instead of a local in main()
We are modifying it after setjmp and then accessing it after the jump,
so it cannot be a local.
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D40415
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sh/main.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/sh/main.c b/bin/sh/main.c index a77f9528064d..3dd2b0d83738 100644 --- a/bin/sh/main.c +++ b/bin/sh/main.c @@ -100,7 +100,13 @@ static char *find_dot_file(char *); int main(int argc, char *argv[]) { - struct stackmark smark = {0}, smark2; + /* + * As smark is accessed after a longjmp, it cannot be a local in main(). + * The C standard specifies that the values of non-volatile local + * variables are unspecified after a jump if modified between the + * setjmp and longjmp. + */ + static struct stackmark smark, smark2; volatile int state; char *shinit; |