diff options
author | Glenn Kasten <gkasten@google.com> | 2013-09-24 11:52:37 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2013-11-20 14:17:01 -0800 |
commit | 663c2247b71086e30bfd3192979d1dd7f15c539e (patch) | |
tree | caedda5629d70de2fcab7506a81852e6c62ea473 /services/audioflinger/AudioFlinger.cpp | |
parent | 30ff92cba19c5acd747631365db1e1084e45ab34 (diff) | |
download | frameworks_av-663c2247b71086e30bfd3192979d1dd7f15c539e.zip frameworks_av-663c2247b71086e30bfd3192979d1dd7f15c539e.tar.gz frameworks_av-663c2247b71086e30bfd3192979d1dd7f15c539e.tar.bz2 |
Consistent error checking for sp<IMemory> and pointer()
There have been concerns that an sp<IMemory> could be non-0, but the
associated pointer() still be NULL. There are rumors this may happen
when a non-0 sp<IMemory> is passed in by client but the shared memory cannot
be re-mapped into mediaserver.
There's also evidence in the early (2009/03/03) pre-git code of checking
pointer() for NULL, after a local allocate() returned a non-0 sp<IMemory>.
It's not clear if this is "cargo cult" paranoia, or if there was a
genuine reason for the check.
In any case, we now consistently check pointer() for sp<IMemory>
input parameters in createTrack() and queueTimedBuffer().
We also check after successful allocate(). If allocate() returns a
non-0 sp<> but NULL pointer(), then treat it as if the allocate() had
returned 0.
Change-Id: I3013ac5766b493d443ecef71711ec861076a623e
Diffstat (limited to 'services/audioflinger/AudioFlinger.cpp')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index c9c9f8a..5cf6ef3 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -476,6 +476,12 @@ sp<IAudioTrack> AudioFlinger::createTrack( goto Exit; } + if (sharedBuffer != 0 && sharedBuffer->pointer() == NULL) { + ALOGE("createTrack() sharedBuffer is non-0 but has NULL pointer()"); + lStatus = BAD_VALUE; + goto Exit; + } + { Mutex::Autolock _l(mLock); PlaybackThread *thread = checkPlaybackThread_l(output); |