Fixed #5149 (false positive: (error) Dereferencing 'memory' after it is deallocated / released)