seleznevae / libfort

C/C++ library to create formatted ASCII tables for console applications
MIT License
493 stars 65 forks source link

segfault in ft_to_string() #58

Closed brlcad closed 3 years ago

brlcad commented 3 years ago

I'm still working on getting a backtrace and simplified code that reproduces, but encountered a segfault/crash if one tries to set the current cell position to an empty/non-existent cell. For example, code filling in what will ultimately be a 2-row, 6-col table out of order like this:

ft_printf(t, "%s|%.2lf|%d|%c", "testing", 21.0/7.0, 12, 'X');
ft_ln(t);
ft_printf(t, "123|321|abc|def|hij|klm");
ft_set_cur_cell(t, 0, 4); // causes badness, but not yet observed
ft_printf(t, "1|2");
ft_to_string(t); // crash
seleznevae commented 3 years ago

Hi, thanks for reporting. Yes, it seems that such cases are treated incorrectly. Didn't expect that somebody will do something like that :)

I'll take a look if it can be fixed.

seleznevae commented 3 years ago

Should be fixed by https://github.com/seleznevae/libfort/pull/59 . If it doesn't work for your case please reopen the issue.

brlcad commented 3 years ago

Awesome, will do. Thanks!