]> git.armaanb.net Git - st.git/blobdiff - st.c
Fix memmove() invocation with src/dst being NULL
[st.git] / st.c
diff --git a/st.c b/st.c
index b1d3791aba830e96f7fc9e45f72947a81796622a..bb8c365207451ffbaea4d803bb9d8d159abf6d72 100644 (file)
--- a/st.c
+++ b/st.c
@@ -2788,8 +2788,11 @@ tresize(int col, int row) {
                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]);