[xiph-commits] r16041 - branches/vorbis-malloccheck/lib
xiphmont at svn.xiph.org
xiphmont at svn.xiph.org
Tue May 26 17:17:20 PDT 2009
Author: xiphmont
Date: 2009-05-26 17:17:20 -0700 (Tue, 26 May 2009)
New Revision: 16041
Modified:
branches/vorbis-malloccheck/lib/bitrate.c
branches/vorbis-malloccheck/lib/block.c
branches/vorbis-malloccheck/lib/codebook.c
branches/vorbis-malloccheck/lib/info.c
branches/vorbis-malloccheck/lib/mapping0.c
Log:
Check for error status being returned by libogg bitpacking.
Bitpacking write errors are a new feature of libogg requested by
embedded devlopers who only have NULL allocation returns available to
indicate out of heap conditions.
Modified: branches/vorbis-malloccheck/lib/bitrate.c
===================================================================
--- branches/vorbis-malloccheck/lib/bitrate.c 2009-05-27 00:01:47 UTC (rev 16040)
+++ branches/vorbis-malloccheck/lib/bitrate.c 2009-05-27 00:17:20 UTC (rev 16041)
@@ -79,6 +79,7 @@
vorbis_info *vi=vd->vi;
codec_setup_info *ci=vi->codec_setup;
bitrate_manager_info *bi=&ci->bi;
+ int ret=0;
int choice=rint(bm->avgfloat);
long this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
@@ -90,10 +91,10 @@
/* not a bitrate managed stream, but for API simplicity, we'll
buffer the packet to keep the code path clean */
- if(bm->vb)return(-1); /* one has been submitted without
+ if(bm->vb) return -1; /* one has been submitted without
being claimed */
bm->vb=vb;
- return(0);
+ return ret;
}
bm->vb=vb;
@@ -187,6 +188,7 @@
minsize-=oggpack_bytes(vbi->packetblob[choice]);
while(minsize-->0)oggpack_write(vbi->packetblob[choice],0,8);
this_bits=oggpack_bytes(vbi->packetblob[choice])*8;
+ if(oggpack_writecheck(vbi->packetblob[choice]) ret = OV_EFAULT;
}
@@ -224,7 +226,7 @@
bm->avg_reservoir+=this_bits-avg_target_bits;
}
- return(0);
+ return ret;
}
int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,ogg_packet *op){
Modified: branches/vorbis-malloccheck/lib/block.c
===================================================================
--- branches/vorbis-malloccheck/lib/block.c 2009-05-27 00:01:47 UTC (rev 16040)
+++ branches/vorbis-malloccheck/lib/block.c 2009-05-27 00:17:20 UTC (rev 16041)
@@ -94,6 +94,9 @@
if(v->analysisp){
vorbis_block_internal *vbi=
vb->internal=_ogg_calloc(1,sizeof(vorbis_block_internal));
+
+ if(!vbi) goto vbi_errout;
+
vbi->ampmax=-9999;
for(i=0;i<PACKETBLOBS;i++){
@@ -103,11 +106,17 @@
vbi->packetblob[i]=
_ogg_calloc(1,sizeof(oggpack_buffer));
}
+ if(!vbi->packetblob[i]) goto vbi_errout;
oggpack_writeinit(vbi->packetblob[i]);
+ if(oggpack_writecheck(vbi->packetblob[i])) goto vbi_errout;
}
}
return(0);
+
+ vbi_errout:
+ vorbis_block_clear(vb);
+ return OV_EFAULT;
}
void *_vorbis_block_alloc(vorbis_block *vb,long bytes){
Modified: branches/vorbis-malloccheck/lib/codebook.c
===================================================================
--- branches/vorbis-malloccheck/lib/codebook.c 2009-05-27 00:01:47 UTC (rev 16040)
+++ branches/vorbis-malloccheck/lib/codebook.c 2009-05-27 00:17:20 UTC (rev 16041)
@@ -141,7 +141,7 @@
return(-1);
}
- return(0);
+ return oggpack_writecheck(opb);
}
/* unpacks a codebook from the packet buffer into the codebook struct,
Modified: branches/vorbis-malloccheck/lib/info.c
===================================================================
--- branches/vorbis-malloccheck/lib/info.c 2009-05-27 00:01:47 UTC (rev 16040)
+++ branches/vorbis-malloccheck/lib/info.c 2009-05-27 00:17:20 UTC (rev 16041)
@@ -546,14 +546,16 @@
}
int vorbis_commentheader_out(vorbis_comment *vc,
- ogg_packet *op){
+ ogg_packet *op){
oggpack_buffer opb;
oggpack_writeinit(&opb);
if(_vorbis_pack_comment(&opb,vc)) return OV_EIMPL;
+ if(oggpack_writecheck(&opb)) return OV_EFAULT;
op->packet = _ogg_malloc(oggpack_bytes(&opb));
+ if(!op->packet) return OV_EFAULT;
memcpy(op->packet, opb.buffer, oggpack_bytes(&opb));
op->bytes=oggpack_bytes(&opb);
@@ -584,6 +586,10 @@
oggpack_writeinit(&opb);
if(_vorbis_pack_info(&opb,vi))goto err_out;
+ if(oggpack_writecheck(&opb)){
+ ret = OV_EFAULT;
+ goto err_out;
+ }
/* build the packet */
if(b->header)_ogg_free(b->header);
@@ -600,6 +606,10 @@
oggpack_reset(&opb);
if(_vorbis_pack_comment(&opb,vc))goto err_out;
+ if(oggpack_writecheck(&opb)){
+ ret = OV_EFAULT;
+ goto err_out;
+ }
if(b->header1)_ogg_free(b->header1);
b->header1=_ogg_malloc(oggpack_bytes(&opb));
@@ -615,6 +625,10 @@
oggpack_reset(&opb);
if(_vorbis_pack_books(&opb,vi))goto err_out;
+ if(oggpack_writecheck(&opb)){
+ ret = OV_EFAULT;
+ goto err_out;
+ }
if(b->header2)_ogg_free(b->header2);
b->header2=_ogg_malloc(oggpack_bytes(&opb));
Modified: branches/vorbis-malloccheck/lib/mapping0.c
===================================================================
--- branches/vorbis-malloccheck/lib/mapping0.c 2009-05-27 00:01:47 UTC (rev 16040)
+++ branches/vorbis-malloccheck/lib/mapping0.c 2009-05-27 00:17:20 UTC (rev 16041)
@@ -498,7 +498,8 @@
/* this algorithm is hardwired to floor 1 for now; abort out if
we're *not* floor1. This won't happen unless someone has
broken the encode setup lib. Guard it anyway. */
- if(ci->floor_type[info->floorsubmap[submap]]!=1)return(-1);
+ if(ci->floor_type[info->floorsubmap[submap]]!=1)
+ return OV_EIMPL;
floor_posts[i][PACKETBLOBS/2]=
floor1_fit(vb,b->flr[info->floorsubmap[submap]],
@@ -745,7 +746,10 @@
seq++;
total+=ci->blocksizes[vb->W]/4+ci->blocksizes[vb->nW]/4;
#endif
- return(0);
+
+ if(oggpack_writecheck(opb)) return OV_EFAULT;
+ return 0;
+
}
static int mapping0_inverse(vorbis_block *vb,vorbis_info_mapping *l){
More information about the commits
mailing list