Commit da656823 authored by hammad zafar's avatar hammad zafar
Browse files

resolve runtime error caused by empty location structure in the request

parent cf7fe401
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -591,9 +591,10 @@ func predictedQosPost(w http.ResponseWriter, r *http.Request) {

		var geocoordinates []gisClient.GeoCoordinate
		for _, routeInfo := range route.RouteInfo {
			if routeInfo.Location == nil {
				log.Error("Mandatory location parameter not present in routeInfo")
				http.Error(w, "Mandatory location parameter not present in routeInfo", http.StatusBadRequest)
			// empty location attribute will cause a runtime error: invalid memory address or nil pointer dereference
			if routeInfo.Location == nil || routeInfo.Location.GeoArea == nil {
				log.Error("Mandatory attribute location is either empty or not present in routeInfo")
				http.Error(w, "Mandatory attribute routes.routeInfo.location is either empty or not present in the request in at least one of the routeInfo structures.", http.StatusBadRequest)
				return
			}