core: safety check for double free in q_malloc as in f_malloc