Commit 6c56a973 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry

Multiple small fixes.

* Tags were being freed even if not initialized if
   op_fetch_headers() failed on the first link.
  The logic for handling completely empty links would leak, also.
* Ignore fragment identifiers in http URLs instead of rejecting
   them.
* Get the current link in seeking_example's verify_seek when
   op_read_native() fails to return it for us.
parent 737cbf57
...@@ -158,6 +158,7 @@ static void verify_seek(OggOpusFile *_of,opus_int64 _byte_offset, ...@@ -158,6 +158,7 @@ static void verify_seek(OggOpusFile *_of,opus_int64 _byte_offset,
if(nsamples<0){ if(nsamples<0){
fprintf(stderr,"\nFailed to read PCM data after seek: %i\n",nsamples); fprintf(stderr,"\nFailed to read PCM data after seek: %i\n",nsamples);
nfailures++; nfailures++;
li=op_current_link(_of);
} }
for(lj=0;lj<li;lj++){ for(lj=0;lj<li;lj++){
duration=op_pcm_total(_of,lj); duration=op_pcm_total(_of,lj);
......
...@@ -232,7 +232,6 @@ static int op_parse_url_impl(OpusParsedURL *_dst,const char *_src){ ...@@ -232,7 +232,6 @@ static int op_parse_url_impl(OpusParsedURL *_dst,const char *_src){
const char *port_end; const char *port_end;
const char *path; const char *path;
const char *path_end; const char *path_end;
const char *fragment_end;
const char *uri_end; const char *uri_end;
scheme_end=_src+strspn(_src,OP_URL_SCHEME); scheme_end=_src+strspn(_src,OP_URL_SCHEME);
if(OP_UNLIKELY(*scheme_end!=':') if(OP_UNLIKELY(*scheme_end!=':')
...@@ -307,12 +306,10 @@ static int op_parse_url_impl(OpusParsedURL *_dst,const char *_src){ ...@@ -307,12 +306,10 @@ static int op_parse_url_impl(OpusParsedURL *_dst,const char *_src){
This doesn't get sent to the server. This doesn't get sent to the server.
Some day we should add support for Media Fragment URIs Some day we should add support for Media Fragment URIs
<http://www.w3.org/TR/media-frags/>.*/ <http://www.w3.org/TR/media-frags/>.*/
if(*path_end=='#'){ if(*path_end=='#')uri_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG);
uri_end=fragment_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG);
}
else uri_end=path_end; else uri_end=path_end;
/*If there's anything left, this was not a valid URL.*/ /*If there's anything left, this was not a valid URL.*/
if(OP_UNLIKELY(*path_end!='\0'))return OP_EINVAL; if(OP_UNLIKELY(*uri_end!='\0'))return OP_EINVAL;
_dst->scheme=op_string_range_dup(_src,scheme_end); _dst->scheme=op_string_range_dup(_src,scheme_end);
if(OP_UNLIKELY(_dst->scheme==NULL))return OP_EFAULT; if(OP_UNLIKELY(_dst->scheme==NULL))return OP_EFAULT;
op_string_tolower(_dst->scheme); op_string_tolower(_dst->scheme);
......
...@@ -1353,7 +1353,6 @@ static int op_open1(OggOpusFile *_of, ...@@ -1353,7 +1353,6 @@ static int op_open1(OggOpusFile *_of,
_of->seekable=seekable; _of->seekable=seekable;
/*Don't seek yet. /*Don't seek yet.
Set up a 'single' (current) logical bitstream entry for partial open.*/ Set up a 'single' (current) logical bitstream entry for partial open.*/
_of->nlinks=1;
_of->links=(OggOpusLink *)_ogg_malloc(sizeof(*_of->links)); _of->links=(OggOpusLink *)_ogg_malloc(sizeof(*_of->links));
/*The serialno gets filled in later by op_fetch_headers().*/ /*The serialno gets filled in later by op_fetch_headers().*/
ogg_stream_init(&_of->os,-1); ogg_stream_init(&_of->os,-1);
...@@ -1364,6 +1363,7 @@ static int op_open1(OggOpusFile *_of, ...@@ -1364,6 +1363,7 @@ static int op_open1(OggOpusFile *_of,
ret=op_fetch_headers(_of,&_of->links[0].head,&_of->links[0].tags, ret=op_fetch_headers(_of,&_of->links[0].head,&_of->links[0].tags,
&_of->serialnos,&_of->nserialnos,&_of->cserialnos,pog); &_of->serialnos,&_of->nserialnos,&_of->cserialnos,pog);
if(OP_UNLIKELY(ret<0))break; if(OP_UNLIKELY(ret<0))break;
_of->nlinks=1;
_of->links[0].offset=0; _of->links[0].offset=0;
_of->links[0].data_offset=_of->offset; _of->links[0].data_offset=_of->offset;
_of->links[0].pcm_end=-1; _of->links[0].pcm_end=-1;
...@@ -1374,8 +1374,10 @@ static int op_open1(OggOpusFile *_of, ...@@ -1374,8 +1374,10 @@ static int op_open1(OggOpusFile *_of,
/*This link was empty, but we already have the BOS page for the next one in /*This link was empty, but we already have the BOS page for the next one in
og. og.
We can't seek, so start processing the next link right now.*/ We can't seek, so start processing the next link right now.*/
opus_tags_clear(&_of->links[0].tags);
_of->nlinks=0;
if(!seekable)_of->cur_link++;
pog=&og; pog=&og;
_of->cur_link++;
} }
if(OP_UNLIKELY(ret<0)){ if(OP_UNLIKELY(ret<0)){
/*Don't auto-close the stream on failure.*/ /*Don't auto-close the stream on failure.*/
......
Markdown is supported
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