Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad malloc in player_start_decoding_threads #146

Open
martri opened this issue Nov 23, 2015 · 0 comments
Open

Bad malloc in player_start_decoding_threads #146

martri opened this issue Nov 23, 2015 · 0 comments

Comments

@martri
Copy link

martri commented Nov 23, 2015

Hello,

The malloc for DecoderData at `player_start_decoding_threads' is being passed size-of-pointer and not size-of-struct.

I was getting random SIGSEGVs due to DecoderData being corrupt (I build with ndk r10e and run on Android 5.1); once applying the fix it seems to work fine.

Thank you and kind regards,
Marco.

diff --git a/library-jni/jni/player.c b/library-jni/jni/player.c
index 7ffdd33..44657b3 100644
--- a/library-jni/jni/player.c
+++ b/library-jni/jni/player.c
@@ -2058,7 +2058,7 @@ int player_start_decoding_threads(struct Player *player) {
        goto end;
    }
    for (i = 0; i < player->caputre_streams_no; ++i) {
-       struct DecoderData * decoder_data = malloc(sizeof(decoder_data));
+       struct DecoderData * decoder_data = malloc(sizeof(*decoder_data));
        *decoder_data = (struct DecoderData) {player: player, stream_no: i};
        ret = pthread_create(&player->decode_threads[i], &attr, player_decode,
                decoder_data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant