[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-readline] segmentation fault in rl_parse_and_bind(char*)
From: |
Jo Van Bulck |
Subject: |
[Bug-readline] segmentation fault in rl_parse_and_bind(char*) |
Date: |
Fri, 17 Oct 2014 17:54:42 +0000 |
Hi all,
When trying to parse a string as if it has been read from the inputrc
file, using the 'rl_parse_and_bind(char *line)' function, I get a
segmentation fault when passing any non-empy string. I run Archlinux
with readline version 'readline 6.3.006-1'.
The following C program is a minimal reproduction of the bug.
/*
* A modified readline example
* (taken from
http://cnswww.cns.cwru.edu/php/chet/readline/readline.html)
* to demonstrate a bug in the rl_parse_and_bind(char*) function.
*
* compile with "gcc readline-bug-example.c -lreadline -o
readline-bug-example"
* rl version: readline 6.3.006-1
*/
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#define PARSE_STRING "set completion-ignore-case on"
int main() {
/* A static variable for holding the line. */
static char *line_read = (char *) NULL;
/* TODO the next line causes a segmentation fault for
* any non-empty string;
*/
rl_parse_and_bind(PARSE_STRING);
while (line_read = readline("> ")) {
printf("You entered '%s'\n", line_read);
/* If the buffer has already been allocated,
return the memory to the free pool. */
if (line_read) {
free (line_read);
line_read = (char *) NULL;
}
}
exit(0);
}
Executing the above program in gdb outputs: "Program received signal
SIGSEGV, Segmentation fault.
0x00007ffff7bb3285 in rl_parse_and_bind () from /usr/lib/libreadline.so.6"
Any ideas on how to fix this?
Regards
- [Bug-readline] segmentation fault in rl_parse_and_bind(char*),
Jo Van Bulck <=