[uim-commit] r2244 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Wed Nov 23 01:37:37 PST 2005
Author: kzk
Date: 2005-11-23 01:37:26 -0800 (Wed, 23 Nov 2005)
New Revision: 2244
Modified:
branches/r5rs/sigscheme/operations.c
Log:
* sigscheme/operations.c
- (ScmOp_make_string): change error message
- (ScmOp_make_vector): more strict length check
- (ScmOp_vector_ref): more strict index range check
- (ScmOp_vector_setd): more strict index range check
Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c 2005-11-23 09:33:13 UTC (rev 2243)
+++ branches/r5rs/sigscheme/operations.c 2005-11-23 09:37:26 UTC (rev 2244)
@@ -1160,7 +1160,7 @@
if (len == 0)
return Scm_NewMutableStringCopying("");
if (len < 0)
- ERR_OBJ("length out of range", length);
+ ERR_OBJ("length must be a positive integer", length);
/* extract fillstr */
if (NO_MORE_ARG(args)) {
@@ -1504,6 +1504,10 @@
ASSERT_INTP(vector_len);
+ /* sanity check */
+ if (SCM_INT_VALUE(vector_len) < 0)
+ ERR_OBJ("length must be a positive integer", vector_len);
+
/* allocate vector */
len = SCM_INT_VALUE(vector_len);
vec = (ScmObj*)malloc(sizeof(ScmObj) * len);
@@ -1548,15 +1552,24 @@
ASSERT_VECTORP(vec);
ASSERT_INTP(scm_k);
+ /* sanity check */
+ if (SCM_INT_VALUE(scm_k) < 0 || SCM_VECTOR_LEN(vec) <= SCM_INT_VALUE(scm_k))
+ ERR_OBJ("index out of range", scm_k);
+
return SCM_VECTOR_REF(vec, scm_k);
}
ScmObj ScmOp_vector_setd(ScmObj vec, ScmObj scm_k, ScmObj obj)
{
DECLARE_FUNCTION("vector-set!", ProcedureFixed3);
+
ASSERT_VECTORP(vec);
ASSERT_INTP(scm_k);
+ /* sanity check */
+ if (SCM_INT_VALUE(scm_k) < 0 || SCM_VECTOR_LEN(vec) <= SCM_INT_VALUE(scm_k))
+ ERR_OBJ("index out of range", scm_k);
+
SCM_VECTOR_SET_REF(vec, scm_k, obj);
return SCM_UNDEF;
More information about the uim-commit
mailing list