diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-08 01:58:31 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-08 01:58:31 +0000 |
commit | 36cfe460a09423f9507b6961c957a8f16dd7c474 (patch) | |
tree | 8335abf6adb94c476c51931e0615f94424a1ad33 /ext | |
parent | 381821deea75d11a496401256c0267f2ff53183e (diff) |
merge revision(s) 34254,34256:
* ext/readline/readline.c (readline_attempted_completion_function):
empty completion result does not mean memory error.
* ext/readline/readline.c (readline_attempted_completion_function):
fix compile error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34479 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/readline/readline.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 34ce023bea..eb163e1af4 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -667,12 +667,12 @@ readline_attempted_completion_function(const char *text, int start, int end) #endif case_fold = RTEST(rb_attr_get(mReadline, completion_case_fold)); ary = rb_funcall(proc, rb_intern("call"), 1, rb_locale_str_new_cstr(text)); - if (TYPE(ary) != T_ARRAY) + if (!RB_TYPE_P(ary, T_ARRAY)) ary = rb_Array(ary); matches = RARRAY_LEN(ary); - if (matches == 0) - return NULL; - result = ALLOC_N(char *, matches + 2); + if (matches == 0) return NULL; + result = (char**)malloc((matches + 2)*sizeof(char*)); + if (result == NULL) rb_raise(rb_eNoMemError, "failed to allocate memory"); for (i = 0; i < matches; i++) { temp = rb_obj_as_string(RARRAY_PTR(ary)[i]); result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1); |