Ensure MakeTemporaryFile() returns 0 and not NULL if error encountered
SFUndoTostring() - Close file when done. Return 0 if error

static scan complained about resource leak due to file not getting closed.
Made routine return 0 if error encountered.
gcc warning: suggest parentheses around assignment used as truth value
free(txt) - static scan complained of resource leak.
scan check... fix a couple of resource leaks
Merge pull request #906 from JoesCat/master

some more scan check fixes