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.
Loading
Please register or sign in to comment