mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Fixed how the original TTY state is preserved
In find_tty_state(), we changed how we expand fd_orig as an original pre-modified copy of fd_setup. We realloc the fd_orig array and copy the fd_setup into it first, before touching the fd_setup array.
This commit is contained in:
4
CHANGES
4
CHANGES
@@ -10,6 +10,10 @@ The following are the changes from calc version 2.14.2.0 to date:
|
|||||||
in find_tty_state() could move the fd_setup array. Thanks goes to
|
in find_tty_state() could move the fd_setup array. Thanks goes to
|
||||||
<GitHub user mattdm> for reporting this bug!
|
<GitHub user mattdm> for reporting this bug!
|
||||||
|
|
||||||
|
In find_tty_state(), we changed how we expand fd_orig as an original
|
||||||
|
pre-modified copy of fd_setup. We realloc the fd_orig array and copy
|
||||||
|
the fd_setup into it first, before touching the fd_setup array.
|
||||||
|
|
||||||
|
|
||||||
The following are the changes from calc version 2.14.1.2 to date:
|
The following are the changes from calc version 2.14.1.2 to date:
|
||||||
|
|
||||||
|
17
lib_calc.c
17
lib_calc.c
@@ -796,6 +796,15 @@ find_tty_state(int fd)
|
|||||||
/*
|
/*
|
||||||
* no empty slots exist, realloc another slot
|
* no empty slots exist, realloc another slot
|
||||||
*/
|
*/
|
||||||
|
/* expand fd_orig as an original pre-modified copy of fd_setup */
|
||||||
|
new_fd_orig = (ttystruct *)realloc(fd_orig, sizeof(fd_orig[0]) *
|
||||||
|
(fd_setup_len+1));
|
||||||
|
if (new_fd_orig == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fd_orig = new_fd_orig;
|
||||||
|
memcpy(fd_orig, fd_setup, sizeof(fd_orig[0]) * (fd_setup_len+1));
|
||||||
|
|
||||||
/* expand fd_setup */
|
/* expand fd_setup */
|
||||||
new_fd_setup = (int *)realloc(fd_setup, sizeof(fd_setup[0]) *
|
new_fd_setup = (int *)realloc(fd_setup, sizeof(fd_setup[0]) *
|
||||||
(fd_setup_len+1));
|
(fd_setup_len+1));
|
||||||
@@ -805,14 +814,6 @@ find_tty_state(int fd)
|
|||||||
fd_setup = new_fd_setup;
|
fd_setup = new_fd_setup;
|
||||||
new_fd_setup[fd_setup_len] = -1;
|
new_fd_setup[fd_setup_len] = -1;
|
||||||
|
|
||||||
/* expand fd_orig */
|
|
||||||
new_fd_orig = (ttystruct *)realloc(fd_orig, sizeof(fd_orig[0]) *
|
|
||||||
(fd_setup_len+1));
|
|
||||||
if (new_fd_orig == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
fd_orig = new_fd_orig;
|
|
||||||
|
|
||||||
/* expand fd_cur */
|
/* expand fd_cur */
|
||||||
new_fd_cur = (ttystruct *)realloc(fd_cur, sizeof(fd_cur[0]) *
|
new_fd_cur = (ttystruct *)realloc(fd_cur, sizeof(fd_cur[0]) *
|
||||||
(fd_setup_len+1));
|
(fd_setup_len+1));
|
||||||
|
Reference in New Issue
Block a user