Permalink
Browse files

Fix bug in -> func causing seg fault on bad index.

  • Loading branch information...
1 parent 831c58d commit 7306435d8ce7a363a8444c2117472bb3550178ea @seven1m committed Jul 8, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 src/lib/list.c
View
@@ -13,7 +13,9 @@ LValue *l_func_list_get(LValue *args, LClosure *closure) {
LValue *index = l_list_get(args, 1);
l_assert_is(list, L_LIST_TYPE, L_ERR_MISSING_LIST, closure);
l_assert_is(index, L_NUM_TYPE, L_ERR_MISSING_INDEX, closure);
- return l_list_get(list, mpz_get_si(index->core.num));
+ LValue *value = l_list_get(list, mpz_get_si(index->core.num));
+ if(value == NULL) value = l_value_new(L_NIL_TYPE, closure);
+ return value;
}
LValue *l_func_count(LValue *args, LClosure *closure) {

0 comments on commit 7306435

Please sign in to comment.