gBroutin / gstreamer-java

Automatically exported from code.google.com/p/gstreamer-java
0 stars 0 forks source link

Gst.init() fails with arguments with non-ASCII chars #96

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create tutoral program 
http://code.google.com/p/gstreamer-java/wiki/VideoPlayerTutorial
2. Supply filename containing non-latin (non-ASCII) chars in path (eg. 
"/home/goga/Видео/Sintel.mp4" ("Видео" -> means "video" in Russian).
3. Run tutorial program.

Instead of movie play program will crash with message:
--------------------
Exception in thread "main" java.lang.IndexOutOfBoundsException: Bounds exceeds 
available space : size=28, offset=33
    at com.sun.jna.Memory.boundsCheck(Memory.java:168)
    at com.sun.jna.Memory.setString(Memory.java:654)
    at org.gstreamer.Gst$NativeArgs.<init>(Gst.java:82)
    at org.gstreamer.Gst.init(Gst.java:276)
    at ru.tsapp.goga.testgst.VideoPlayer.main(VideoPlayer.java:18)
--------------------

I used version gstreamer-java-1.5 but problem exists in current version also. 
In my case single russian char produces two bytes, while Memory object was 
created for number of chars (not bytes) in argument string.

Problem is in line 119 of Gst.java source file (current r526 revision). 

Line 119:

arg = new Memory(args[i].length() + 1);

I think has to be changed to:

arg = new Memory(args[i].getBytes().length + 1);

The same problem may occure in line 114:

Memory arg = new Memory(progname.length() + 4);

has to be changed to:

Memory arg = new Memory(progname.getBytes().length + 4);

Original issue reported on code.google.com by hazard157@gmail.com on 9 Jan 2012 at 4:29

GoogleCodeExporter commented 8 years ago
thanks.
r549.

Original comment by lfar...@lfarkas.org on 13 Jan 2012 at 10:04