The stream object wasn't set to NULL after freeing causing a double free attempt on the cleanup path. (cherry picked from commit e3b8808ba764e06f68785a2bbdd8b7ab00b71fa4)