diff src/content.c @ 318:9b79433f0976 noffle

[svn] * src/content.c: Tighten up checks when accessing content vector.
author bears
date Fri, 21 Feb 2003 16:01:28 +0000
parents 5eece4dfd945
children 8e14809bf172
line wrap: on
line diff
--- a/src/content.c	Thu Feb 20 10:57:54 2003 +0000
+++ b/src/content.c	Fri Feb 21 16:01:28 2003 +0000
@@ -1,7 +1,7 @@
 /*
   content.c
 
-  $Id: content.c 413 2002-12-27 21:48:25Z bears $
+  $Id: content.c 453 2003-02-21 16:01:28Z bears $
 */
 
 #if HAVE_CONFIG_H
@@ -64,8 +64,11 @@
 Bool
 Cont_validNumb( int n )
 {
+    int ofs = n - cont.vecFirst;
+    
     return ( n != 0 && n >= cont.first && n <= cont.last
-             && cont.elem[ n - cont.vecFirst ] );
+             && ofs >= 0 && ofs < cont.size
+	     && cont.elem[ ofs ] != NULL );
 }
 
 void
@@ -88,7 +91,11 @@
     int i;
 
     for ( i = 0; i < cont.size; ++i )
-        del_Over( cont.elem[ i ] );
+    {
+	if ( cont.elem[ i ] != NULL )
+	    del_Over( cont.elem[ i ] );
+	cont.elem[ i ] = NULL;
+    }
     cont.size = 0;
 }
 
@@ -172,7 +179,7 @@
 
 	/*
 	  Check for end article(s) being cancelled. Need to ensure we
-	  don't re-use and article number.
+	  don't re-use end article number.
 	 */
 	grpLast = Grp_last( name );
 	if ( cont.last < grpLast )