diff options
author | Bartosz Nitka <niteria@gmail.com> | 2016-10-06 05:40:24 -0700 |
---|---|---|
committer | Bartosz Nitka <niteria@gmail.com> | 2016-10-07 03:07:13 -0700 |
commit | e41b9c614984b63c4660018cecde682453e083e5 (patch) | |
tree | 21237358709a4b236b687dcc5187896695aef245 /rts/RtsFlags.c | |
parent | cbe11d5fefefce518c246b470350a5a3bf8efbd6 (diff) | |
download | haskell-e41b9c614984b63c4660018cecde682453e083e5.tar.gz |
Fix memory leak from #12664
This fixes the leak with `setProgArgv`. The problem was
that `setProgArgv` would not free the objects pointed
to by `prog_argc`, `prog_argv` when the globals were
changed resulting in a leak.
The only strictly necessary change is in `rts/RtsFlags.c`, but
the code in `System.Environment` was a bit confusing and not
exception safe, so I refactored it.
Test Plan: ./validate
Reviewers: simonmar, ezyang, austin, hvr, bgamari, erikd
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2576
GHC Trac Issues: #12664
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r-- | rts/RtsFlags.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c index c994a0ce88..4bd544ee29 100644 --- a/rts/RtsFlags.c +++ b/rts/RtsFlags.c @@ -1943,6 +1943,7 @@ getProgArgv(int *argc, char **argv[]) void setProgArgv(int argc, char *argv[]) { + freeArgv(prog_argc,prog_argv); prog_argc = argc; prog_argv = copyArgv(argc,argv); setProgName(prog_argv); |