Merge fix from master for coverity CID 1170168: Use after free.