#vulnerable code 
                             @Override
	public void beginObject(WorldObject object) {

		/* build the previous object (if it's inside the bounding box) */

		boolean isInsideBbox = true;

		if (currentObject != null && currentObject.getPrimaryMapElement() != null) {

			MapElement mapElement = currentObject.getPrimaryMapElement();

			VectorXZ center = null;

			if (mapElement instanceof MapNode) {
				center = ((MapNode) mapElement).getPos();
			} else if (mapElement instanceof MapWaySegment) {
				center = ((MapWaySegment) mapElement).getCenter();
			} else if (mapElement instanceof MapArea) {
				center = ((MapArea) mapElement).getOuterPolygon().getCenter();
			}

			isInsideBbox = bbox.contains(center);

		}

		if (!currentTriangles.isEmpty() && isInsideBbox) {
			objects.add(buildCurrentObject());
		}

		/* start a new object */

		currentObject = object;
		currentTriangles = new HashMap<Material, FrontendPbfTarget.TriangleData>();

	} 
                            #location 22 
                            #vulnerability type NULL_DEREFERENCE
#fixed code
                             @Override
	public void beginObject(WorldObject object) {

		finishCurrentObject();

		/* start a new object */

		currentObject = object;
		currentTriangles = new HashMap<Material, FrontendPbfTarget.TriangleData>();

	}