From adc02cce188dbc20400197af7ee6f7ceac2e108e Mon Sep 17 00:00:00 2001 From: Mikael Djurfeldt Date: Thu, 14 Aug 1997 14:58:25 +0000 Subject: [PATCH] * gsubr.c (scm_gsubr_apply): From Radey Shouman : "The switch in scm_gsubr_apply that dispatches on the number of actual args has a default case reporting an internal error. This is a vestige from a version that mallocated a SCM vector to hold the arguments. In the current version this check is too late: if it ever happens we will have already overstepped the bounds of the array. Also, the patch [...] adds a check for too many actual arguments." mdj: Removed check for "internal programming error". --- libguile/gsubr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libguile/gsubr.c b/libguile/gsubr.c index f755f8fe7..c3e865dd2 100644 --- a/libguile/gsubr.c +++ b/libguile/gsubr.c @@ -124,11 +124,15 @@ scm_gsubr_apply(args) SCM v[10]; /* must agree with greatest supported arity */ int typ = SCM_INUM(GSUBR_TYPE(self)); int i, n = GSUBR_REQ(typ) + GSUBR_OPT(typ) + GSUBR_REST(typ); +#if 0 + SCM_ASSERT(n <= sizeof(v)/sizeof(SCM), + self, "internal programming error", s_gsubr_apply); +#endif args = SCM_CDR(args); for (i = 0; i < GSUBR_REQ(typ); i++) { #ifndef RECKLESS if (SCM_IMP(args)) - scm_wrong_num_args (SCM_SNAME(GSUBR_PROC(self))); + wnargs: scm_wrong_num_args (SCM_SNAME(GSUBR_PROC(self))); #endif v[i] = SCM_CAR(args); args = SCM_CDR(args); @@ -143,8 +147,9 @@ scm_gsubr_apply(args) } if (GSUBR_REST(typ)) v[i] = args; + else + SCM_ASRTGO(SCM_NULLP(args), wnargs); switch (n) { - default: scm_wta(self, "internal programming error", s_gsubr_apply); case 2: return (*fcn)(v[0], v[1]); case 3: return (*fcn)(v[0], v[1], v[2]); case 4: return (*fcn)(v[0], v[1], v[2], v[3]);