From 6c56a9739723335b82eff400fbd90770a69602d2 Mon Sep 17 00:00:00 2001 From: "Timothy B. Terriberry" Date: Mon, 1 Oct 2012 08:41:36 -0700 Subject: [PATCH] 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. --- examples/seeking_example.c | 1 + src/http.c | 7 ++----- src/opusfile.c | 6 ++++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/seeking_example.c b/examples/seeking_example.c index 7b30d8e..1418cb1 100644 --- a/examples/seeking_example.c +++ b/examples/seeking_example.c @@ -158,6 +158,7 @@ static void verify_seek(OggOpusFile *_of,opus_int64 _byte_offset, if(nsamples<0){ fprintf(stderr,"\nFailed to read PCM data after seek: %i\n",nsamples); nfailures++; + li=op_current_link(_of); } for(lj=0;lj.*/ - if(*path_end=='#'){ - uri_end=fragment_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG); - } + if(*path_end=='#')uri_end=path_end+1+strspn(path_end+1,OP_URL_QUERY_FRAG); else uri_end=path_end; /*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); if(OP_UNLIKELY(_dst->scheme==NULL))return OP_EFAULT; op_string_tolower(_dst->scheme); diff --git a/src/opusfile.c b/src/opusfile.c index 4579ceb..293b87c 100644 --- a/src/opusfile.c +++ b/src/opusfile.c @@ -1353,7 +1353,6 @@ static int op_open1(OggOpusFile *_of, _of->seekable=seekable; /*Don't seek yet. Set up a 'single' (current) logical bitstream entry for partial open.*/ - _of->nlinks=1; _of->links=(OggOpusLink *)_ogg_malloc(sizeof(*_of->links)); /*The serialno gets filled in later by op_fetch_headers().*/ ogg_stream_init(&_of->os,-1); @@ -1364,6 +1363,7 @@ static int op_open1(OggOpusFile *_of, ret=op_fetch_headers(_of,&_of->links[0].head,&_of->links[0].tags, &_of->serialnos,&_of->nserialnos,&_of->cserialnos,pog); if(OP_UNLIKELY(ret<0))break; + _of->nlinks=1; _of->links[0].offset=0; _of->links[0].data_offset=_of->offset; _of->links[0].pcm_end=-1; @@ -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 og. 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; - _of->cur_link++; } if(OP_UNLIKELY(ret<0)){ /*Don't auto-close the stream on failure.*/ -- GitLab