Fix nil pointer dereference in ToOCSS when Price.Type is nil
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m57s
Some checks failed
Build and Push Docker Image / build_and_push (push) Failing after 2m57s
Handle optional Price.Type field properly to prevent panic when converting booking to OCSS format.
This commit is contained in:
@@ -200,10 +200,12 @@ func (b *CarpoolServiceBooking) ToOCSS() ocss.Booking {
|
||||
}
|
||||
if b.Price != nil {
|
||||
pricetype := ocss.Unknown
|
||||
if *b.Price.Type == CarpoolServicePriceType_FREE {
|
||||
pricetype = ocss.Free
|
||||
} else if *b.Price.Type == CarpoolServicePriceType_PAYING {
|
||||
pricetype = ocss.Paying
|
||||
if b.Price.Type != nil {
|
||||
if *b.Price.Type == CarpoolServicePriceType_FREE {
|
||||
pricetype = ocss.Free
|
||||
} else if *b.Price.Type == CarpoolServicePriceType_PAYING {
|
||||
pricetype = ocss.Paying
|
||||
}
|
||||
}
|
||||
price = ocss.Price{
|
||||
Type: &pricetype,
|
||||
|
||||
Reference in New Issue
Block a user