Fixed multiple memory leaks when using sync fs functions