Bug fix: avoid double free.