diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-22 04:47:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-09-22 04:47:37 +0000 |
commit | 9dcc08646f0a26b61ae162daffeb0ce5fbc60f0e (patch) | |
tree | bf615848ad985f59c4154afcc05d8765506ddb51 /st.c | |
parent | 94fe90346327efaea9c7dff75ea9ff0ed5a6ed04 (diff) |
* hash.c (rb_hash_rehash): add iteration check. [ruby-dev:24301]
* st.c (st_foreach): add deep check.
* array.c (rb_ary_collect_bang): element size might change during
comparison. [ruby-dev:24300]
* array.c (rb_ary_reject_bang): ditto. [ruby-dev:24300]
* array.c (rb_ary_eql): ditto. [ruby-dev:24300]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -3,6 +3,7 @@ /* static char sccsid[] = "@(#) st.c 5.1 89/12/14 Crucible"; */ #include "config.h" +#include "defines.h" #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -492,8 +493,21 @@ st_foreach(table, func, arg) for(i = 0; i < table->num_bins; i++) { last = 0; for(ptr = table->bins[i]; ptr != 0;) { - retval = (*func)(ptr->key, ptr->record, arg); + retval = (*func)(ptr->key, ptr->record, arg, 0); switch (retval) { + case ST_CHECK: /* check if hash is modified during iteration */ + tmp = 0; + if (i < table->num_bins) { + for (tmp = table->bins[i]; tmp; tmp=tmp->next) { + if (tmp == ptr) break; + } + } + if (!tmp) { + /* call func with error notice */ + retval = (*func)(0, 0, arg, 1); + return; + } + /* fall through */ case ST_CONTINUE: last = ptr; ptr = ptr->next; |