Ok, I see now. Makes sense. Changing the example code to:

    char *a = malloc(strlen(PARSE_STRING)+1);
    strcpy(a,PARSE_STRING);
    rl_parse_and_bind(a);

works indeed. Thanks for the quick reply :-)
________________________________________
Van: Chet Ramey [[email protected]]
Verzonden: vrijdag 17 oktober 2014 20:57
Aan: Jo Van Bulck; [email protected]
CC: [email protected]
Onderwerp: Re: [Bug-readline] segmentation fault in rl_parse_and_bind(char*)

On 10/17/14, 1:54 PM, Jo Van Bulck wrote:
> 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'.

It depends on the behavior of your compiler.  rl_parse_and_bind wants to
modify the string it's passed by temporarily putting in NULs and later
restoring the original characters as part of tokenizing the line, similar
to strtok/strsep.  If your compiler puts string constants into read-only
memory pages, you'll get a seg fault if you pass such a string constant to
rl_parse_and_bind.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    [email protected]    http://cnswww.cns.cwru.edu/~chet/
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline

Reply via email to