aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-01 14:48:04 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2020-08-01 15:04:58 +0900
commitb6e6807993c770c5d2e069d8741f5dadf0b38069 (patch)
tree190ccdceb3f6f2d3500e63b48126f6e72da73c97 /array.c
parent32bec658c1947e8a21884757462342465c089ce0 (diff)
downloadruby-b6e6807993c770c5d2e069d8741f5dadf0b38069.tar.gz
Initialize memo pointer and use it consistently to silence gcc 7+
Diffstat (limited to 'array.c')
-rw-r--r--array.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/array.c b/array.c
index 5c611fc5db..87e7fb358e 100644
--- a/array.c
+++ b/array.c
@@ -6931,7 +6931,7 @@ flatten(VALUE ary, int level)
{
long i;
VALUE stack, result, tmp = 0, elt, vmemo;
- st_table *memo;
+ st_table *memo = 0;
st_data_t id;
for (i = 0; i < RARRAY_LEN(ary); i++) {
@@ -6974,7 +6974,7 @@ flatten(VALUE ary, int level)
}
tmp = rb_check_array_type(elt);
if (RBASIC(result)->klass) {
- if (level < 0) {
+ if (memo) {
RB_GC_GUARD(vmemo);
st_clear(memo);
}
@@ -6984,7 +6984,7 @@ flatten(VALUE ary, int level)
rb_ary_push(result, elt);
}
else {
- if (level < 0) {
+ if (memo) {
id = (st_data_t)tmp;
if (st_is_member(memo, id)) {
st_clear(memo);
@@ -7001,7 +7001,7 @@ flatten(VALUE ary, int level)
if (RARRAY_LEN(stack) == 0) {
break;
}
- if (level < 0) {
+ if (memo) {
id = (st_data_t)ary;
st_delete(memo, &id, 0);
}
@@ -7010,7 +7010,7 @@ flatten(VALUE ary, int level)
ary = rb_ary_pop(stack);
}
- if (level < 0) {
+ if (memo) {
st_clear(memo);
}