summaryrefslogtreecommitdiffstats
path: root/socket.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-04 23:04:16 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-04 23:04:16 -0700
commita9af2631068edfcb26b1823cf63b078ddf75dd79 (patch)
tree2f70b2c0e370d161e05e5a04dd053e9e61245be0 /socket.h
parent0cb57f957f6ea07a8e33173d39716716db455d30 (diff)
downloadtxr-a9af2631068edfcb26b1823cf63b078ddf75dd79.tar.gz
txr-a9af2631068edfcb26b1823cf63b078ddf75dd79.tar.bz2
txr-a9af2631068edfcb26b1823cf63b078ddf75dd79.zip
regex: fix double free corruption bug.
Unfortunately, the nfa_state_free function doesn't check the static flag on a character set and just calls chr_set_destroy. So when one of the static character sets is planted into the NFA graph, when that graph is garbage-collected, it blows away the static character set. Then when that happens twice for the same set, boom! We make an alteration to make the destruction more defensive. Callers of char_set_destroy are no longer saddled with the responsibility of honoring the static flag buried in the object. Instead, that function itself check the static flag. An argument is provided to force the deletion in spite of the static flag; that is needed for the global cleanup of the static states. (Only occurs if txr is run with --free-all and cleanly exited.) * regex.c (char_set_destroy): Take extra argument, force. If the set is marked static, then do nothing, unless force is nonzero. (char_set_cobj_destroy): Don't check the static flag, just call char_set_destroy, force zero. (nfa_state_free): Add force zero argument to char_set_destroy call. The double free bug is thereby fixed here; static sets are protected. (regex_free_all): Force all the char_set_destroy calls here.
Diffstat (limited to 'socket.h')
0 files changed, 0 insertions, 0 deletions