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

Fix memory leak if AudioStreamBuilder::openStream() fails. #243

Merged
merged 1 commit into from Oct 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/oboe/AudioStreamBuilder.h
Expand Up @@ -305,6 +305,8 @@ class AudioStreamBuilder : public AudioStreamBase {
/**
* Create and open a stream object based on the current settings.
*
* The caller owns the pointer to the AudioStream object.
*
* @param stream pointer to a variable to receive the stream address
* @return OBOE_OK if successful or a negative error code
*/
Expand All @@ -317,7 +319,9 @@ class AudioStreamBuilder : public AudioStreamBase {
/**
* Create an AudioStream object. The AudioStream must be opened before use.
*
* @return pointer to an AudioStream object.
* The caller owns the pointer.
*
* @return pointer to an AudioStream object or nullptr.
*/
oboe::AudioStream *build();

Expand Down
2 changes: 2 additions & 0 deletions src/common/AudioStreamBuilder.cpp
Expand Up @@ -86,6 +86,8 @@ Result AudioStreamBuilder::openStream(AudioStream **streamPP) {
Result result = streamP->open(); // TODO review API
if (result == Result::OK) {
*streamPP = streamP;
} else {
delete streamP;
}
return result;
}
Expand Down