[xiph-commits] r13162 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Thu Jun 21 00:06:25 PDT 2007


Author: xiphmont
Date: 2007-06-21 00:06:25 -0700 (Thu, 21 Jun 2007)
New Revision: 13162

Modified:
   trunk/vorbis/lib/block.c
   trunk/vorbis/lib/info.c
   trunk/vorbis/lib/psy.c
   trunk/vorbis/lib/vorbisfile.c
Log:
Numerous small changes to resolve possible and certain issues found by 
Coverity.



Modified: trunk/vorbis/lib/block.c
===================================================================
--- trunk/vorbis/lib/block.c	2007-06-21 06:33:37 UTC (rev 13161)
+++ trunk/vorbis/lib/block.c	2007-06-21 07:06:25 UTC (rev 13162)
@@ -326,20 +326,23 @@
       }
 
       if(b->flr){
-	for(i=0;i<ci->floors;i++)
-	  _floor_P[ci->floor_type[i]]->
-	    free_look(b->flr[i]);
+	if(ci)
+	  for(i=0;i<ci->floors;i++)
+	    _floor_P[ci->floor_type[i]]->
+	      free_look(b->flr[i]);
 	_ogg_free(b->flr);
       }
       if(b->residue){
-	for(i=0;i<ci->residues;i++)
-	  _residue_P[ci->residue_type[i]]->
-	    free_look(b->residue[i]);
+	if(ci)
+	  for(i=0;i<ci->residues;i++)
+	    _residue_P[ci->residue_type[i]]->
+	      free_look(b->residue[i]);
 	_ogg_free(b->residue);
       }
       if(b->psy){
-	for(i=0;i<ci->psys;i++)
-	  _vp_psy_clear(b->psy+i);
+	if(ci)
+	  for(i=0;i<ci->psys;i++)
+	    _vp_psy_clear(b->psy+i);
 	_ogg_free(b->psy);
       }
 
@@ -352,8 +355,9 @@
     }
     
     if(v->pcm){
-      for(i=0;i<vi->channels;i++)
-	if(v->pcm[i])_ogg_free(v->pcm[i]);
+      if(vi)
+	for(i=0;i<vi->channels;i++)
+	  if(v->pcm[i])_ogg_free(v->pcm[i]);
       _ogg_free(v->pcm);
       if(v->pcmret)_ogg_free(v->pcmret);
     }

Modified: trunk/vorbis/lib/info.c
===================================================================
--- trunk/vorbis/lib/info.c	2007-06-21 06:33:37 UTC (rev 13161)
+++ trunk/vorbis/lib/info.c	2007-06-21 07:06:25 UTC (rev 13162)
@@ -135,8 +135,8 @@
     if(vc->user_comments)_ogg_free(vc->user_comments);
 	if(vc->comment_lengths)_ogg_free(vc->comment_lengths);
     if(vc->vendor)_ogg_free(vc->vendor);
+    memset(vc,0,sizeof(*vc));
   }
-  memset(vc,0,sizeof(*vc));
 }
 
 /* blocksize 0 is guaranteed to be short, 1 is guaranteed to be long.
@@ -600,12 +600,14 @@
   memset(op_comm,0,sizeof(*op_comm));
   memset(op_code,0,sizeof(*op_code));
 
-  if(b->header)_ogg_free(b->header);
-  if(b->header1)_ogg_free(b->header1);
-  if(b->header2)_ogg_free(b->header2);
-  b->header=NULL;
-  b->header1=NULL;
-  b->header2=NULL;
+  if(b){
+    if(b->header)_ogg_free(b->header);
+    if(b->header1)_ogg_free(b->header1);
+    if(b->header2)_ogg_free(b->header2);
+    b->header=NULL;
+    b->header1=NULL;
+    b->header2=NULL;
+  }
   return(ret);
 }
 

Modified: trunk/vorbis/lib/psy.c
===================================================================
--- trunk/vorbis/lib/psy.c	2007-06-21 06:33:37 UTC (rev 13161)
+++ trunk/vorbis/lib/psy.c	2007-06-21 07:06:25 UTC (rev 13162)
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: psychoacoustics not including preecho
- last mod: $Id: psy.c,v 1.81 2002/10/21 07:00:11 xiphmont Exp $
+ last mod: $Id$
 
  ********************************************************************/
 
@@ -553,7 +553,10 @@
   int i;
 
   int lo, hi;
-  float R, A, B, D;
+  float R=0.f;
+  float A=0.f;
+  float B=0.f;
+  float D=1.f;
   float w, x, y;
 
   tN = tX = tXX = tY = tXY = 0.f;

Modified: trunk/vorbis/lib/vorbisfile.c
===================================================================
--- trunk/vorbis/lib/vorbisfile.c	2007-06-21 06:33:37 UTC (rev 13161)
+++ trunk/vorbis/lib/vorbisfile.c	2007-06-21 07:06:25 UTC (rev 13162)
@@ -986,8 +986,8 @@
     ogg_packet op;
     int lastblock=0;
     int accblock=0;
-    int thisblock;
-    int eosflag;
+    int thisblock=0;
+    int eosflag=0; 
 
     ogg_stream_init(&work_os,vf->current_serialno); /* get the memory ready */
     ogg_stream_reset(&work_os); /* eliminate the spurious OV_HOLE
@@ -1009,7 +1009,7 @@
 	    }else{
 	      
 	      if(eosflag)
-	      ogg_stream_packetout(&vf->os,NULL);
+		ogg_stream_packetout(&vf->os,NULL);
 	      else
 		if(lastblock)accblock+=(lastblock+thisblock)>>2;
 	    }	    



More information about the commits mailing list