We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1519

Summary: RWops structure is allocated but uninitialized.
Product: SDL Reporter: sir_belial
Component: fileAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: gabomdq
Version: HG 2.0   
Hardware: ARM   
OS: Android (All)   
Attachments: Patch to fix above problems.

Description sir_belial 2012-06-15 01:33:26 UTC
Created attachment 876 [details]
Patch to fix above problems.

In the SDL_RWFromFile function in SDL_rwops.c a RWops structure is allocated (line 450). This structure is then passed to Android_JNI_FileOpen (SDL_Android.cpp). This function calls various Java methods and jumps to the failure: mark if an exception is raised somewhere. When freeing the resources, members of the uninitialized RWops structure might be used, ie. if the ctx->hidden.androidio.readableByteChannelRef is not set because the file is not available (or any other java exception), the check against NULL might still return true. 

I resolved it by initializing the relevant members to NULL when entering the SDL_RWFromFile structure.
Comment 1 Gabriel Jacobo 2012-06-20 07:26:38 UTC
Fixed, thanks! http://hg.libsdl.org/SDL/rev/fbb84f5b985f