mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
* alist.c (scm_sloppy_assq, scm_sloppy_assv, scm_sloppy_assoc):
Don't crash when passed an improper list terminated by a non-immediate value.
This commit is contained in:
parent
fcd69146b1
commit
cf18adf033
1 changed files with 17 additions and 28 deletions
|
@ -76,16 +76,13 @@ scm_sloppy_assq(x, alist)
|
|||
SCM x;
|
||||
SCM alist;
|
||||
{
|
||||
SCM tmp;
|
||||
for(;SCM_NIMP(alist);alist = SCM_CDR(alist))
|
||||
|
||||
for (; SCM_NIMP (alist) && SCM_CONSP (alist); alist = SCM_CDR (alist))
|
||||
{
|
||||
if (SCM_CONSP(alist))
|
||||
{
|
||||
tmp = SCM_CAR(alist);
|
||||
SCM tmp = SCM_CAR(alist);
|
||||
if (SCM_NIMP (tmp) && SCM_CONSP (tmp) && (SCM_CAR (tmp)==x))
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
|
@ -98,18 +95,14 @@ scm_sloppy_assv(x, alist)
|
|||
SCM x;
|
||||
SCM alist;
|
||||
{
|
||||
SCM tmp;
|
||||
for(;SCM_NIMP(alist);alist = SCM_CDR(alist))
|
||||
for (; SCM_NIMP (alist) && SCM_CONSP (alist); alist = SCM_CDR (alist))
|
||||
{
|
||||
if (SCM_CONSP(alist))
|
||||
{
|
||||
tmp = SCM_CAR(alist);
|
||||
SCM tmp = SCM_CAR(alist);
|
||||
if (SCM_NIMP (tmp)
|
||||
&& SCM_CONSP (tmp)
|
||||
&& SCM_NFALSEP (scm_eqv_p (SCM_CAR (tmp), x)))
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
|
@ -121,18 +114,14 @@ scm_sloppy_assoc(x, alist)
|
|||
SCM x;
|
||||
SCM alist;
|
||||
{
|
||||
SCM tmp;
|
||||
for(;SCM_NIMP(alist);alist = SCM_CDR(alist))
|
||||
for (; SCM_NIMP (alist) && SCM_CONSP (alist); alist = SCM_CDR (alist))
|
||||
{
|
||||
if (SCM_CONSP(alist))
|
||||
{
|
||||
tmp = SCM_CAR(alist);
|
||||
SCM tmp = SCM_CAR(alist);
|
||||
if (SCM_NIMP (tmp)
|
||||
&& SCM_CONSP (tmp)
|
||||
&& SCM_NFALSEP (scm_equal_p (SCM_CAR (tmp), x)))
|
||||
return tmp;
|
||||
}
|
||||
}
|
||||
return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue