1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Add memsets after allocation of all Backend implementors.

Now every struct that implements the Backend trait is completely
cleared before we start initialising any of its fields. This will mean
I can add new fields that default to 0 or NULL, without having to mess
around initialising them explicitly everywhere.
This commit is contained in:
Simon Tatham 2021-10-30 14:51:24 +01:00
parent 27f00038e1
commit 76dc28552c
8 changed files with 8 additions and 0 deletions

View File

@ -156,6 +156,7 @@ static char *raw_init(const BackendVtable *vt, Seat *seat,
char *loghost; char *loghost;
raw = snew(Raw); raw = snew(Raw);
memset(raw, 0, sizeof(Raw));
raw->plug.vt = &Raw_plugvt; raw->plug.vt = &Raw_plugvt;
raw->backend.vt = vt; raw->backend.vt = vt;
raw->s = NULL; raw->s = NULL;

View File

@ -233,6 +233,7 @@ static char *rlogin_init(const BackendVtable *vt, Seat *seat,
char *loghost; char *loghost;
rlogin = snew(Rlogin); rlogin = snew(Rlogin);
memset(rlogin, 0, sizeof(Rlogin));
rlogin->plug.vt = &Rlogin_plugvt; rlogin->plug.vt = &Rlogin_plugvt;
rlogin->backend.vt = vt; rlogin->backend.vt = vt;
rlogin->s = NULL; rlogin->s = NULL;

View File

@ -683,6 +683,7 @@ static char *supdup_init(const BackendVtable *x, Seat *seat,
const char *utf8 = "\033%G"; const char *utf8 = "\033%G";
supdup = snew(struct supdup_tag); supdup = snew(struct supdup_tag);
memset(supdup, 0, sizeof(Supdup));
supdup->plug.vt = &fn_table; supdup->plug.vt = &fn_table;
supdup->backend.vt = &supdup_backend; supdup->backend.vt = &supdup_backend;
supdup->logctx = logctx; supdup->logctx = logctx;

View File

@ -721,6 +721,7 @@ static char *telnet_init(const BackendVtable *vt, Seat *seat,
int addressfamily; int addressfamily;
telnet = snew(Telnet); telnet = snew(Telnet);
memset(telnet, 0, sizeof(Telnet));
telnet->plug.vt = &Telnet_plugvt; telnet->plug.vt = &Telnet_plugvt;
telnet->backend.vt = vt; telnet->backend.vt = vt;
telnet->conf = conf_copy(conf); telnet->conf = conf_copy(conf);

View File

@ -414,6 +414,7 @@ static void pty_open_master(Pty *pty)
static Pty *new_pty_struct(void) static Pty *new_pty_struct(void)
{ {
Pty *pty = snew(Pty); Pty *pty = snew(Pty);
memset(pty, 0, sizeof(Pty));
pty->conf = NULL; pty->conf = NULL;
pty->pending_eof = false; pty->pending_eof = false;
bufchain_init(&pty->output_data); bufchain_init(&pty->output_data);

View File

@ -294,6 +294,7 @@ static char *serial_init(const BackendVtable *vt, Seat *seat,
seat_set_trust_status(seat, false); seat_set_trust_status(seat, false);
serial = snew(Serial); serial = snew(Serial);
memset(serial, 0, sizeof(Serial));
serial->backend.vt = vt; serial->backend.vt = vt;
*backend_handle = &serial->backend; *backend_handle = &serial->backend;

View File

@ -232,6 +232,7 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
seat_set_trust_status(seat, false); seat_set_trust_status(seat, false);
conpty = snew(ConPTY); conpty = snew(ConPTY);
memset(conpty, 0, sizeof(ConPTY));
conpty->pseudoconsole = pcon; conpty->pseudoconsole = pcon;
pcon_needs_cleanup = false; pcon_needs_cleanup = false;
conpty->outpipe = in_w; conpty->outpipe = in_w;

View File

@ -212,6 +212,7 @@ static char *serial_init(const BackendVtable *vt, Seat *seat,
seat_set_trust_status(seat, false); seat_set_trust_status(seat, false);
serial = snew(Serial); serial = snew(Serial);
memset(serial, 0, sizeof(Serial));
serial->port = INVALID_HANDLE_VALUE; serial->port = INVALID_HANDLE_VALUE;
serial->out = serial->in = NULL; serial->out = serial->in = NULL;
serial->bufsize = 0; serial->bufsize = 0;