andmarti1424 / sc-im

sc-im - Spreadsheet Calculator Improvised -- An ncurses spreadsheet program for terminal
Other
4.88k stars 208 forks source link

Assigning empty label in date field will cause segfault #878

Closed cskeeters closed 4 months ago

cskeeters commented 5 months ago

Pressing \<Enter> after loading the following file results in segfault.

segf.sc

# This data file was generated by the Spreadsheet Calculator Improvised (sc-im)
# You almost certainly shouldn't edit it.

newsheet "Dates"
movetosheet "Dates"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 0
nb_frozen_cols 0
nb_frozen_screenrows 0
nb_frozen_screencols 0
format A 22 2 0
label A0 = "12/24/1978"
let A0 = 283327200
fmt A0 "d%b-%Y"
goto A0

I suspect there is something I don't understand about how this is working. I thought that the label was converted to the number of seconds since the epoch when <C-d> was pressed, and fmt (set with :format) formats the number for display in the cell to the user. It seems that entering a new label with \ will automatically convert the text to the epoch, and an empty string will not result in -1 and display as "1/1/1970" but will crash the application.

andmarti1424 commented 4 months ago

@cskeeters thanks for reporting this. will take a look at it. it certainly shouldnt break as its happening now.

andmarti1424 commented 4 months ago

@cskeeters please update to latest commit and retry. thank you

marrs commented 4 months ago

The segfault is fixed but the label is lost. Is that intended behaviour?

andmarti1424 commented 4 months ago

@marrs yes indeed.

cskeeters commented 4 months ago

The fix in the dev branch fixed the issue. No segfault and removed label.