all repos — st @ 56abffb4b67f235d20de30f29ba027ab34c171e3

st (suckless terminal) config

Fix memmove() invocation with src/dst being NULL

This fixes a segmentation fault on some systems.
sin sin@2f30.org
commit

56abffb4b67f235d20de30f29ba027ab34c171e3

parent

aff35af275cb82eb876630c9256298ea1d1b2b57

1 files changed, 5 insertions(+), 2 deletions(-)

jump to
M st.cst.c

@@ -2788,8 +2788,11 @@ for(i = 0; i <= term.c.y - row; i++) {

free(term.line[i]); free(term.alt[i]); } - memmove(term.line, term.line + i, row * sizeof(Line)); - memmove(term.alt, term.alt + i, row * sizeof(Line)); + /* ensure that both src and dst are not NULL */ + if (i > 0) { + memmove(term.line, term.line + i, row * sizeof(Line)); + memmove(term.alt, term.alt + i, row * sizeof(Line)); + } for(i += row; i < term.row; i++) { free(term.line[i]); free(term.alt[i]);