fyhertz / libstreaming

A solution for streaming H.264, H.263, AMR, AAC using RTP on Android
Apache License 2.0
3.49k stars 1.08k forks source link

A potential bug by a wrong indexer in an inner loop #253

Open lifove opened 7 years ago

lifove commented 7 years ago

Hi

In a recent snapshot, I've found a suspicious code at src/net/majorkernelpanic/streaming/video/CodecManager.java

153             String[] types = codecInfo.getSupportedTypes();
154                 for (int i = 0; i < types.length; i++) {
155                      if (types[i].equalsIgnoreCase(mimeType)) {
156                            MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(mimeType);
157 
158                             boolean software = false;
159                             for (int k=0;k<SOFTWARE_ENCODERS.length;k++) {
160                                 if (codecInfo.getName().equalsIgnoreCase(SOFTWARE_ENCODERS[i])) {
161                                       software = true;
162                                 }
163                              }

Currently, SOFTWARE_ENCODERS has only one value, so it might not be an issue if the length of types are not > 1. But wanted to report just in case. Thanks!