Getting vertex positions of a mesh-works in editor, doesn't work in packaged build

I have such code, why it behaves different in packaged game(returns huge values) and what’s the correct approach?

		if (FPositionVertexBuffer* buf = &MeshComponent->GetStaticMesh()->GetRenderData()->LODResources[0].VertexBuffers.PositionVertexBuffer){
			float maxDist = 0;
			const int32 VertexCount = buf->GetNumVertices();
			for (int32 Index = 0; Index < VertexCount; Index++){
				const FVector3f vertex = buf->VertexPosition(Index);
				if (vertex.Z < 150 && FVector(vertex.X, vertex.Y, 0).Length() > maxDist){
					maxDist = FVector(vertex.X, vertex.Y, 0).Length();
				}
			}
		}