aboutsummaryrefslogtreecommitdiffhomepage
path: root/util.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-10-26 06:34:33 +1000
committerGravatar axel <axel@liljencrantz.se>2006-10-26 06:34:33 +1000
commitc627509e598b5cd612f41a76b1a022af111dfcd6 (patch)
tree18031de110f8b5bf4314875fb4178a8896f9eaf7 /util.c
parent4502fc74c36e1e776377362584b8b883c7a66594 (diff)
Make al_pop return null on empty lists instead of crashing
darcs-hash:20061025203433-ac50b-5d3a18d788d6f36dffe1136664f029a500989db9.gz
Diffstat (limited to 'util.c')
-rw-r--r--util.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/util.c b/util.c
index 5f00c54b..3c0ee968 100644
--- a/util.c
+++ b/util.c
@@ -948,7 +948,16 @@ void al_truncate( array_list_t *l, int new_sz )
static anything_t al_pop_generic( array_list_t *l )
{
- anything_t e = l->arr[--l->pos];
+ anything_t e;
+
+ if( l->pos <= 0 )
+ {
+ memset( &e, 0, sizeof(anything_t ) );
+ return e;
+ }
+
+
+ e = l->arr[--l->pos];
if( (l->pos*3 < l->size) && (l->size < MIN_SIZE) )
{
anything_t *old_arr = l->arr;