Fix GH-16802: open_basedir bypass using curl extension And fix a memleak while here. Closes GH-16804.