1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-03 08:10:31 +02:00

Bounds error in vector_handle_ref/set is implementation error

* libguile/vectors.c: bounds are already checked unless impl is called
  directly, so don't check again.
* libguile/strings.c, libguile/bitvectors.c: fix comments.
This commit is contained in:
Daniel Llorens 2013-04-26 17:59:45 +02:00 committed by Andy Wingo
parent 86263a20cd
commit d2053db7d8
3 changed files with 5 additions and 9 deletions

View file

@ -852,8 +852,7 @@ scm_istr2bve (SCM str)
return res; return res;
} }
/* FIXME: We know that bitvector is such, so can skip the checks in /* FIXME: We know that bitvector is such, so can skip the checks */
scm_c_bitvector_... */
static SCM static SCM
bitvector_handle_ref (SCM bitvector, size_t pos) bitvector_handle_ref (SCM bitvector, size_t pos)
{ {

View file

@ -2460,8 +2460,7 @@ scm_i_get_substring_spec (size_t len,
*cend = scm_to_unsigned_integer (end, *cstart, len); *cend = scm_to_unsigned_integer (end, *cstart, len);
} }
/* FIXME: We know that bitvector is such, so can skip the checks in /* FIXME: We know that string is such, so can skip checks */
scm_c_string_... */
static SCM static SCM
string_handle_ref (SCM string, size_t index) string_handle_ref (SCM string, size_t index)
{ {

View file

@ -39,7 +39,7 @@
#include "libguile/bdw-gc.h" #include "libguile/bdw-gc.h"
#include <assert.h>
#define VECTOR_MAX_LENGTH (SCM_T_BITS_MAX >> 8) #define VECTOR_MAX_LENGTH (SCM_T_BITS_MAX >> 8)
@ -436,16 +436,14 @@ SCM_DEFINE (scm_vector_move_right_x, "vector-move-right!", 5, 0, 0,
static SCM static SCM
vector_handle_ref (SCM vector, size_t idx) vector_handle_ref (SCM vector, size_t idx)
{ {
if (idx >= SCM_I_VECTOR_LENGTH (vector)) assert (idx < SCM_I_VECTOR_LENGTH (vector));
scm_out_of_range ("vector-handle-ref", scm_from_size_t (idx));
return SCM_I_VECTOR_WELTS(vector)[idx]; return SCM_I_VECTOR_WELTS(vector)[idx];
} }
static void static void
vector_handle_set (SCM vector, size_t idx, SCM val) vector_handle_set (SCM vector, size_t idx, SCM val)
{ {
if (idx >= SCM_I_VECTOR_LENGTH (vector)) assert (idx < SCM_I_VECTOR_LENGTH (vector));
scm_out_of_range ("vector-handle-set!", scm_from_size_t (idx));
SCM_I_VECTOR_WELTS(vector)[idx] = val; SCM_I_VECTOR_WELTS(vector)[idx] = val;
} }