Mercurial > noffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
317:eef64bccd0e2 | 318:9b79433f0976 |
---|---|
1 /* | 1 /* |
2 content.c | 2 content.c |
3 | 3 |
4 $Id: content.c 413 2002-12-27 21:48:25Z bears $ | 4 $Id: content.c 453 2003-02-21 16:01:28Z bears $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
62 } | 62 } |
63 | 63 |
64 Bool | 64 Bool |
65 Cont_validNumb( int n ) | 65 Cont_validNumb( int n ) |
66 { | 66 { |
67 int ofs = n - cont.vecFirst; | |
68 | |
67 return ( n != 0 && n >= cont.first && n <= cont.last | 69 return ( n != 0 && n >= cont.first && n <= cont.last |
68 && cont.elem[ n - cont.vecFirst ] ); | 70 && ofs >= 0 && ofs < cont.size |
71 && cont.elem[ ofs ] != NULL ); | |
69 } | 72 } |
70 | 73 |
71 void | 74 void |
72 Cont_delete( int n ) | 75 Cont_delete( int n ) |
73 { | 76 { |
86 clearCont( void ) | 89 clearCont( void ) |
87 { | 90 { |
88 int i; | 91 int i; |
89 | 92 |
90 for ( i = 0; i < cont.size; ++i ) | 93 for ( i = 0; i < cont.size; ++i ) |
91 del_Over( cont.elem[ i ] ); | 94 { |
95 if ( cont.elem[ i ] != NULL ) | |
96 del_Over( cont.elem[ i ] ); | |
97 cont.elem[ i ] = NULL; | |
98 } | |
92 cont.size = 0; | 99 cont.size = 0; |
93 } | 100 } |
94 | 101 |
95 static void | 102 static void |
96 setupEmpty( const char *name ) | 103 setupEmpty( const char *name ) |
170 { | 177 { |
171 int grpLast; | 178 int grpLast; |
172 | 179 |
173 /* | 180 /* |
174 Check for end article(s) being cancelled. Need to ensure we | 181 Check for end article(s) being cancelled. Need to ensure we |
175 don't re-use and article number. | 182 don't re-use end article number. |
176 */ | 183 */ |
177 grpLast = Grp_last( name ); | 184 grpLast = Grp_last( name ); |
178 if ( cont.last < grpLast ) | 185 if ( cont.last < grpLast ) |
179 extendCont( grpLast - cont.first + 1 ); | 186 extendCont( grpLast - cont.first + 1 ); |
180 } | 187 } |