Skip to content

@jareks /gist:1035322
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.