修复一个可能触发 NPE 的问题

ZLMediaKit 回应中可能没有 tracks 字段,导致报 NPE,使得资源没有被正确释放
pull/1760/head
南宫茜 2025-01-21 16:57:44 +08:00 committed by GitHub
parent 464c989986
commit cf3204de71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 1 deletions

View File

@ -10,6 +10,8 @@ import lombok.Data;
import java.util.List;
import java.util.Map;
import org.springframework.util.ObjectUtils;
/**
*
*/
@ -106,7 +108,7 @@ public class MediaInfo {
}
}
JSONArray jsonArray = jsonObject.getJSONArray("tracks");
if (!jsonArray.isEmpty()) {
if (!ObjectUtils.isEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject trackJson = jsonArray.getJSONObject(i);
Integer channels = trackJson.getInteger("channels");