skmuzeer / spydroid-ipcamera

Automatically exported from code.google.com/p/spydroid-ipcamera
GNU General Public License v3.0
0 stars 0 forks source link

ArrayIndexOutOfBoundsException H264Packetizer #65

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
There is a crash after few first frames are shown on VLC. Seems to be a problem 
with signed int. How about using long instead?

E/AndroidRuntime(21528): FATAL EXCEPTION: Thread-1523
E/AndroidRuntime(21528): java.lang.ArrayIndexOutOfBoundsException: 
src.length=500000 srcPos=60796 dst.length=1500 dstPos=13 length=-1
E/AndroidRuntime(21528):        at java.lang.System.arraycopy(Native Method)
E/AndroidRuntime(21528):        at 
net.majorkernelpanic.rtp.H264Packetizer$SimpleFifo.read(H264Packetizer.java:325)
E/AndroidRuntime(21528):        at 
net.majorkernelpanic.rtp.H264Packetizer$Consumer.send(H264Packetizer.java:247)
E/AndroidRuntime(21528):        at 
net.majorkernelpanic.rtp.H264Packetizer$Consumer.run(H264Packetizer.java:192)

        public int read(byte[] buffer, int offset, int length) {

            //length = length>available() ? available() : length;

            length = length<0 ? 0 : length;

After added sanity check above:

E/AndroidRuntime(22702): FATAL EXCEPTION: Thread-1536
E/AndroidRuntime(22702): java.lang.IndexOutOfBoundsException: 
length=-511694332, offset=0, buffer size=1500
E/AndroidRuntime(22702):        at 
java.net.DatagramPacket.setLength(DatagramPacket.java:213)
E/AndroidRuntime(22702):        at 
net.majorkernelpanic.rtp.RtpSocket.send(RtpSocket.java:114)
E/AndroidRuntime(22702):        at 
net.majorkernelpanic.rtp.H264Packetizer$Consumer.send(H264Packetizer.java:249)
E/AndroidRuntime(22702):        at 
net.majorkernelpanic.rtp.H264Packetizer$Consumer.run(H264Packetizer.java:192)

Original issue reported on code.google.com by dadeval@gmail.com on 1 Aug 2012 at 9:20