diff options
| author | dgreid@chromium.org <dgreid@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 09:17:07 +0000 |
|---|---|---|
| committer | dgreid@chromium.org <dgreid@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-12 09:17:07 +0000 |
| commit | b7d6fff50fbee0a56739f622f9e0d1711678766f (patch) | |
| tree | 8829e815caaa1140b1d6de0db432703959c36c1e /media/audio/linux/cras_output.cc | |
| parent | ca4460e32b86f405c55b68c4a4997b1cb3cd8e80 (diff) | |
| download | chromium_src-b7d6fff50fbee0a56739f622f9e0d1711678766f.zip chromium_src-b7d6fff50fbee0a56739f622f9e0d1711678766f.tar.gz chromium_src-b7d6fff50fbee0a56739f622f9e0d1711678766f.tar.bz2 | |
CrasOutput: Handle Close() being called after a failed Open().
If Open() fails due to the pipe() or pthread_create() system calls
failing, client_ will be non-null but will have been freed. To fix this,
set client_ to NULL on failures in Open(), and check before using it in
Close().
BUG=132040
TEST=Change the cras library to return errors from the client_connect() or client_run() functions, then watch as the errors cause a crash when you add an audio stream.
Review URL: https://chromiumcodereview.appspot.com/10546090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141638 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/linux/cras_output.cc')
| -rw-r--r-- | media/audio/linux/cras_output.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/media/audio/linux/cras_output.cc b/media/audio/linux/cras_output.cc index a04388a..77eb68f 100644 --- a/media/audio/linux/cras_output.cc +++ b/media/audio/linux/cras_output.cc @@ -120,6 +120,7 @@ bool CrasOutputStream::Open() { int err = cras_client_create(&client_); if (err < 0) { LOG(WARNING) << "Couldn't create CRAS client.\n"; + client_ = NULL; TransitionTo(kInError); return false; } @@ -127,6 +128,7 @@ bool CrasOutputStream::Open() { if (err) { LOG(WARNING) << "Couldn't connect CRAS client.\n"; cras_client_destroy(client_); + client_ = NULL; TransitionTo(kInError); return false; } @@ -135,6 +137,7 @@ bool CrasOutputStream::Open() { if (err) { LOG(WARNING) << "Couldn't run CRAS client.\n"; cras_client_destroy(client_); + client_ = NULL; TransitionTo(kInError); return false; } @@ -149,8 +152,11 @@ void CrasOutputStream::Close() { return; } - cras_client_stop(client_); - cras_client_destroy(client_); + if (client_) { + cras_client_stop(client_); + cras_client_destroy(client_); + client_ = NULL; + } // Signal to the manager that we're closed and can be removed. // Should be last call in the method as it deletes "this". |
