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 - RWops structure is allocated but uninitialized.
Summary: RWops structure is allocated but uninitialized.
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: file (show other bugs)
Version: HG 2.0
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-15 01:33 UTC by sir_belial
Modified: 2012-06-20 07:26 UTC (History)
1 user (show)

See Also:


Attachments
Patch to fix above problems. (440 bytes, patch)
2012-06-15 01:33 UTC, sir_belial
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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