troglobit / editline

A small replacement for GNU readline() for UNIX
https://troglobit.com/projects/editline/
Other
282 stars 58 forks source link

Segmentation violation #18

Closed jmjatlanta closed 6 years ago

jmjatlanta commented 6 years ago

This shows up on macOS 10.13 (and maybe others).

https://github.com/troglobit/editline/blob/534b3897b82f2ecb3a9e46272b00a50299972001/src/editline.c#L178-L182

I believe the realloc should happen before the character is added to the array. Once I made that change, the SIGSEV went away.

Note: The array of items to display had 122 entries, longest 46 (3 columns).

Update: After taking another look, changing the > to a >= will do the trick.

troglobit commented 6 years ago

Thank you for reporting, and fixing, this! :)