fixed: tried to free mapped buffer, unmap if mapped, free otherwise,