Fix memory not alloc bug