This commit fixes potential memory leak of GTM.  The bug was reported
by Andrei Martsinchyk.   He also provided this fix.