[#2212] CID49447:

Restricted scope to prevent concerns about use after free
[#2212] CID49446:

Explicitly null the pointer when we free it, check to make sure it is
reassigned to a non-null value later