util: fix bad memory access