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