Fix memmove() invocation with src/dst being NULL

This fixes a segmentation fault on some systems.
dev
sin 2015-04-15 09:43:06 +01:00 committed by Roberto E. Vargas Caballero
parent aff35af275
commit 56abffb4b6
1 changed files with 5 additions and 2 deletions

7
st.c
View File

@ -2788,8 +2788,11 @@ tresize(int col, int row) {
free(term.line[i]); free(term.line[i]);
free(term.alt[i]); free(term.alt[i]);
} }
memmove(term.line, term.line + i, row * sizeof(Line)); /* ensure that both src and dst are not NULL */
memmove(term.alt, term.alt + i, row * sizeof(Line)); 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++) { for(i += row; i < term.row; i++) {
free(term.line[i]); free(term.line[i]);
free(term.alt[i]); free(term.alt[i]);