Fix double free which could lead in segfault