Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory corruption when a compound variable is unset #49

Merged
merged 1 commit into from
Jun 29, 2020

Commits on Jun 29, 2020

  1. Fix memory corruption when a compound variable is unset

    The following set of commands ends with a memory fault under
    certain circumstances because ksh attempts to free memory
    twice, causing memory corruption:
    
    $ testarray=(1 2)
    $ compound testarray
    $ unset testarray
    $ eval testarray=
    
    The fix is to make sure 'np->nvfun' is a valid pointer before
    attempting to free memory in 'put_tree'. This patch is from
    OpenSUSE: https://build.opensuse.org/package/view_file/shells/ksh/ksh93-nvtree-free.dif?expand=1
    
    src/cmd/ksh93/sh/nvtree.c:
    - Do not try to free memory when 'np->nvfun' and 'val'
      are false.
    
    src/cmd/ksh93/tests/comvar.sh:
    - Add a regression test for the double free problem. The
      reproducer must be run from an executable script
      with 'ksh -c'.
    JohnoKing committed Jun 29, 2020
    Configuration menu
    Copy the full SHA
    ad11740 View commit details
    Browse the repository at this point in the history