From: Martin Ling Date: Mon, 18 Nov 2013 20:08:25 +0000 (+0000) Subject: Additional argument checking for config functions. X-Git-Tag: libserialport-0.1.0~106 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=823690ae3e7c31cab9f14e7efe5402a49380b443;p=libserialport.git Additional argument checking for config functions. --- diff --git a/serialport.c b/serialport.c index eed009a..065a224 100644 --- a/serialport.c +++ b/serialport.c @@ -1010,6 +1010,11 @@ int sp_set_config(struct sp_port *port, struct sp_port_config *config) struct port_data data; struct sp_port_config prev_config; + CHECK_PORT(); + + if (!config) + return SP_ERR_ARG; + TRY(get_config(port, &data, &prev_config)); TRY(set_config(port, &data, config)); @@ -1019,6 +1024,7 @@ int sp_set_config(struct sp_port *port, struct sp_port_config *config) #define CREATE_SETTER(x) int sp_set_##x(struct sp_port *port, int x) { \ struct port_data data; \ struct sp_port_config config; \ + CHECK_PORT(); \ TRY(get_config(port, &data, &config)); \ config.x = x; \ TRY(set_config(port, &data, &config)); \ @@ -1040,6 +1046,8 @@ int sp_set_flowcontrol(struct sp_port *port, int flowcontrol) struct port_data data; struct sp_port_config config; + CHECK_PORT(); + TRY(get_config(port, &data, &config)); if (flowcontrol == SP_FLOWCONTROL_XONXOFF)