Skip to content

Instantly share code, notes, and snippets.

@jareks
Created June 20, 2011 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jareks/1035322 to your computer and use it in GitHub Desktop.
Save jareks/1035322 to your computer and use it in GitHub Desktop.
Ruby 1.9.2 patch
# Copyright (C) 2011 Lunar Logic Polska http://www.lunarlogicpolska.com
# Author: Jaroslaw Skrzypek jaroslaw.skrzypek(at)llp.pl
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/load.c b/load.c
index f8f0551..0484bc0 100644
--- a/load.c
+++ b/load.c
@@ -84,13 +84,13 @@ loaded_feature_path(const char *name, long vlen, const char *feature, long len,
for (i = 0; i < RARRAY_LEN(load_path); ++i) {
VALUE p = RARRAY_PTR(load_path)[i];
- const char *s = StringValuePtr(p);
+ const char *s = RSTRING_PTR(p);
long n = RSTRING_LEN(p);
- if (vlen < n + len + 1) continue;
- if (n && (strncmp(name, s, n) || name[n] != '/')) continue;
- if (strncmp(name + n + 1, feature, len)) continue;
+ if (vlen < n + len + 1 || vlen > n + len + 1 + DLEXT_MAXLEN) continue;
if (name[n+len+1] && name[n+len+1] != '.') continue;
+ if (n && (name[n] != '/' || strncmp(name, s, n))) continue;
+ if (strncmp(name + n + 1, feature, len)) continue;
switch (type) {
case 's':
if (IS_DLEXT(&name[n+len+1])) return p;
@jareks
Copy link
Author

jareks commented Mar 25, 2022

Similar offical ruby patch ruby/ruby@9ce69e7#load.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment