fix avformat source mem leak and segv