Skip to content

Commit ef3ce71

Browse files
committed
merge revision(s) 7ae67e8: [Backport #21568]
[PATCH] load.c: Fix dest and src of MEMMOVE When multiple files with the same name are required, the features_index hash stores the indexes in `$LOADED_FEATURES` array into a darray. The dest and src arguments for `MEMMOVE` were wrongly reversed when inserting a new index in the darray. [Bug #21568]
1 parent a7eb7e7 commit ef3ce71

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

load.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ features_index_add_single_callback(st_data_t *key, st_data_t *value, st_data_t r
284284
if (pos >= 0) {
285285
long *ptr = rb_darray_data_ptr(feature_indexes);
286286
long len = rb_darray_size(feature_indexes);
287-
MEMMOVE(ptr + pos, ptr + pos + 1, long, len - pos - 1);
287+
MEMMOVE(ptr + pos + 1, ptr + pos, long, len - pos - 1);
288288
ptr[pos] = FIX2LONG(offset);
289289
}
290290
}

test/ruby/test_require.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,4 +1035,18 @@ class Object
10351035
end
10361036
RUBY
10371037
end
1038+
1039+
def test_bug_21568
1040+
load_path = $LOAD_PATH.dup
1041+
loaded_featrures = $LOADED_FEATURES.dup
1042+
1043+
$LOAD_PATH.clear
1044+
$LOADED_FEATURES.replace(["foo.so", "a/foo.rb", "b/foo.rb"])
1045+
1046+
assert_nothing_raised(LoadError) { require "foo" }
1047+
1048+
ensure
1049+
$LOAD_PATH.replace(load_path) if load_path
1050+
$LOADED_FEATURES.replace loaded_featrures
1051+
end
10381052
end

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 6
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 57
14+
#define RUBY_PATCHLEVEL 58
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)