dmq: fixed crash caused by freeing pointer too early on tm callback