fix memory leak
Merge pull request #3892 from rablwupei/script_leak

[ci skip]fix memory leak