Fix transport.GetInt(): case nil and delete the unreachable code.
To reproduce the scene: if bandwidth of SDP is not set by client, the SFU server will crash.
@@ -39,6 +39,8 @@ func GetInt(m map[string]interface{}, k string) (int, error) {
val, ok := m[k]
if ok {
switch val.(type) {
+ case nil:
+ return 0, errors.New("value is nil")
case string:
i, err := strconv.ParseInt(val.(string), 10, 64)
if err != nil {
@@ -50,10 +52,6 @@ func GetInt(m map[string]interface{}, k string) (int, error) {
default:
return int(reflect.ValueOf(val).Int()), nil
}
- n, ok := val.(int)
- if ok {
- return n, nil
- }
}
return 0, errors.New("inavlid key or value type")
}
