Fix user after free in dir watcher
Fix potential crash while creating temporary cache_entry