Permalink
Browse files

Allocate storage for the strings, since they're freed

Closes #6.
  • Loading branch information...
Evan Phoenix
Evan Phoenix committed May 26, 2009
1 parent 5562ec6 commit 2ec98ab4eba103f1daff303361dac7b5476499b1
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/ext/readline/readline.c
@@ -148,8 +148,9 @@ readline_attempted_completion_function(text, start, end)
if (matches == 0) return NULL;
result = ALLOC_N(char *, matches + 2);
for (i = 0; i < matches; i++) {
- temp = rb_obj_as_string(rb_ary_entry(ary, i));
- result[i + 1] = RSTRING_PTR(temp);
+ temp = rb_obj_as_string(rb_ary_entry(ary, i));
+ result[i + 1] = ALLOC_N(char, RSTRING_LEN(temp) + 1);
+ strcpy(result[i + 1], RSTRING_PTR(temp));
}
result[matches + 1] = NULL;

0 comments on commit 2ec98ab

Please sign in to comment.