Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c720661c authored by You Kim's avatar You Kim
Browse files

Uninitialized pointer can cause crash.



mpAudioTrack should be initialized in any case.
If getOutputSamplingRate returns ERROR, this won't be initialized.
As a result, deleting this field in dtor can cause crash.

Change-Id: I950d353361b19635302339dac35752a2514d2d80
Signed-off-by: default avatarYou Kim <you.kim72@gmail.com>
parent 2da6e4ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -803,6 +803,7 @@ ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool
    ALOGV("ToneGenerator constructor: streamType=%d, volume=%f", streamType, volume);

    mState = TONE_IDLE;
    mpAudioTrack = NULL;

    if (AudioSystem::getOutputSamplingRate(&mSamplingRate, streamType) != NO_ERROR) {
        ALOGE("Unable to marshal AudioFlinger");
@@ -811,7 +812,6 @@ ToneGenerator::ToneGenerator(audio_stream_type_t streamType, float volume, bool
    mThreadCanCallJava = threadCanCallJava;
    mStreamType = streamType;
    mVolume = volume;
    mpAudioTrack = NULL;
    mpToneDesc = NULL;
    mpNewToneDesc = NULL;
    // Generate tone by chunks of 20 ms to keep cadencing precision