ocket8888 commented on code in PR #7224:
URL: https://github.com/apache/trafficcontrol/pull/7224#discussion_r1042523146


##########
lib/go-tc/deliveryservices.go:
##########
@@ -1632,7 +1632,11 @@ func (ds DeliveryServiceV5) Downgrade() 
DeliveryServiceV4 {
                copy(*downgraded.MatchList, ds.MatchList)
        }
        copy(downgraded.TLSVersions, ds.TLSVersions)
-
+       if len(ds.RequiredCapabilities) == 0 {
+               downgraded.RequiredCapabilities = make([]string, 0)
+       } else {
+               copy(downgraded.RequiredCapabilities, ds.RequiredCapabilities)
+       }

Review Comment:
   This won't work. You can't `copy` more data into a slice than it can hold. 
So when the destination is a nil slice (which by definition has `len` of zero), 
it silently does nothing - there's no room to hold any data. So you have to 
`make` some allocation of data for the new slice either way.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to