Commit 68f18feb authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

Plug possible memory leak on stream open failure.

Not all the failure paths cleaned up after themselves properly.
Thanks to tangobravo for complaining about similar issues in
 libvorbisfile, which prompted me to audit this code.
parent 6587f1de
...@@ -1527,12 +1527,7 @@ static int op_open1(OggOpusFile *_of, ...@@ -1527,12 +1527,7 @@ static int op_open1(OggOpusFile *_of,
if(!seekable)_of->cur_link++; if(!seekable)_of->cur_link++;
pog=&og; pog=&og;
} }
if(OP_UNLIKELY(ret<0)){ if(OP_LIKELY(ret>=0))_of->ready_state=OP_PARTOPEN;
/*Don't auto-close the stream on failure.*/
_of->callbacks.close=NULL;
op_clear(_of);
}
else _of->ready_state=OP_PARTOPEN;
return ret; return ret;
} }
...@@ -1569,6 +1564,9 @@ OggOpusFile *op_test_callbacks(void *_source,const OpusFileCallbacks *_cb, ...@@ -1569,6 +1564,9 @@ OggOpusFile *op_test_callbacks(void *_source,const OpusFileCallbacks *_cb,
if(_error!=NULL)*_error=0; if(_error!=NULL)*_error=0;
return of; return of;
} }
/*Don't auto-close the stream on failure.*/
of->callbacks.close=NULL;
op_clear(of);
_ogg_free(of); _ogg_free(of);
} }
if(_error!=NULL)*_error=ret; if(_error!=NULL)*_error=ret;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment