fix a small bug of mem realloc