fixed potential bug in init_heap