dmq: fixed crash caused by freeing pointer too early on tm callback
(cherry picked from commit 8be7de6d1d383c2e0e476e739a6b3fa5101bac12)