aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin <sin@2f30.org>2015-04-15 09:43:06 +0100
committerRoberto E. Vargas Caballero <k0ga@shike2.com>2015-04-15 10:51:00 +0200
commit56abffb4b67f235d20de30f29ba027ab34c171e3 (patch)
treec79d48f0f624a6f8ffcb9a96dddedf8cf84bd57d
parentaff35af275cb82eb876630c9256298ea1d1b2b57 (diff)
downloadst-56abffb4b67f235d20de30f29ba027ab34c171e3.tar.gz
st-56abffb4b67f235d20de30f29ba027ab34c171e3.tar.bz2
Fix memmove() invocation with src/dst being NULL
This fixes a segmentation fault on some systems.
-rw-r--r--st.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/st.c b/st.c
index b1d3791..bb8c365 100644
--- 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]);