Skip to content
  • niteria's avatar
    Fix memory leak from #12664 · b08ffec0
    niteria authored and Ben Gamari's avatar Ben Gamari committed
    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
    
    (cherry picked from commit e41b9c61)
    b08ffec0