1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

* gsubr.c (scm_gsubr_apply): From Radey Shouman

<shouman@zianet.com>: "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".
This commit is contained in:
Mikael Djurfeldt 1997-08-14 14:58:25 +00:00
parent 4ed948d4f1
commit adc02cce18

View file

@ -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]);