mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
94fe903463
commit
9dcc08646f
5 changed files with 61 additions and 17 deletions
16
st.c
16
st.c
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue