| Summary: | New FileDescriptor based RWops system is broken | ||
|---|---|---|---|
| Product: | SDL | Reporter: | paul |
| Component: | file | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | major | ||
| Priority: | P2 | CC: | gabomdq, philipp.wiesemann |
| Version: | HG 2.0 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: |
Patch to fix the issue.
Patch for not deleted global reference on Android. |
||
There is maybe another problem: The GlobalRef stored in assetFileDescriptorRef is not deleted if the control flow does "goto fallback". It is only deleted if it does "goto failure". This may be fixed if the GlobalRef is created later (after gotos). Created attachment 1029 [details]
Patch for not deleted global reference on Android.
I attached a patch for the problem I tried to describe above (global reference not deleted on error).
I do not know how often exception might happen at "getStartOffset" and "getDeclaredLength" but I think there was a reason the checks were added. Without the described change this part of the source will not be "exception safe" because it leaks.
On the other hand if no exceptions might happen there at all the checks and gotos might be removed to make the source more clear. The the creation of the global reference does not need to be changed.
|
Created attachment 1023 [details] Patch to fix the issue. The newly added Android RWops system for directly accessing the native filehandle does not seek to the correct offset in the file. So if you don't do a seek before reading data, you won't get what you expect. I have attached a patch that fixes the issue for me.