Skip to content
Snippets Groups Projects
Commit 0b2fe85a authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

Fix potential memory leaks with OpusServerInfo.

In op_[v]open_url() and op_[v]test_url(), if we successfully
 connected to the URL but fail to parse it as an Opus stream, then
 we would return to the calling application without clearing any
 OpusServerInfo we might have filled in when connecting.
This contradicts the general contract for user output buffers in
 our APIs, which is that they do not need to be initialized prior
 to a call and that their contents are untouched if a function
 fails (so that an application need do no additional clean-up on
 error).
It would have been possible for an application to avoid these leaks
 by always calling opus_server_info_init() before a call to
 op_[v]open_url() or op_[v]test_url() and always calling
 opus_server_info_clear() afterwards (even on failure), but our
 examples don't do this and no other API of ours requires it.

Fix the potential leaks by wrapping the implementation of
 op_url_stream_vcreate() so we can a) tell if the information was
 requested and b) store it in a separate, local buffer and delay
 copying it to the application until we know we've succeeded.
parent 0221ca95
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment