From: Martin Ling Date: Sat, 23 Nov 2013 20:55:18 +0000 (+0000) Subject: Initialise structure in sp_new_config(). X-Git-Tag: libserialport-0.1.0~53 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=59131d602894f5e2f8776fa9f4736d360f67579f;p=libserialport.git Initialise structure in sp_new_config(). --- diff --git a/serialport.c b/serialport.c index f426fca..3f9989d 100644 --- a/serialport.c +++ b/serialport.c @@ -1467,13 +1467,27 @@ static enum sp_return set_config(struct sp_port *port, struct port_data *data, enum sp_return sp_new_config(struct sp_port_config **config_ptr) { TRACE("%p", config_ptr); + struct sp_port_config *config; if (!config_ptr) RETURN_ERROR(SP_ERR_ARG, "Null result pointer"); - if (!(*config_ptr = malloc(sizeof(struct sp_port_config)))) + *config_ptr = NULL; + + if (!(config = malloc(sizeof(struct sp_port_config)))) RETURN_ERROR(SP_ERR_MEM, "config malloc failed"); + config->baudrate = -1; + config->bits = -1; + config->parity = -1; + config->stopbits = -1; + config->rts = -1; + config->cts = -1; + config->dtr = -1; + config->dsr = -1; + + *config_ptr = config; + RETURN_OK(); }