mem: fix undefined behavior in NUMA-aware mapping