X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fscpi%2Fscpi_vxi.c;h=66e1d7db50adc471c973273139c145d9a33da00a;hp=2b8e50dee5688ce3a7383e29949ee959086d5dc2;hb=0e3c3c80b86b7ea7590225186953ea0c4d603613;hpb=7414fb55cb1ff4472176318d0e1146abfd2b7163 diff --git a/src/scpi/scpi_vxi.c b/src/scpi/scpi_vxi.c index 2b8e50de..66e1d7db 100644 --- a/src/scpi/scpi_vxi.c +++ b/src/scpi/scpi_vxi.c @@ -21,12 +21,12 @@ */ #include -#include +/* vxi.h must the first #include after config.h See commit d40b8557. */ +#include "vxi.h" #include #include #include "libsigrok-internal.h" #include "scpi.h" -#include "vxi.h" #define LOG_PREFIX "scpi_vxi" #define VXI_DEFAULT_TIMEOUT_MS 2000 @@ -195,10 +195,16 @@ static int scpi_vxi_read_data(void *priv, char *buf, int maxlen) if (!read_resp || read_resp->error) { sr_err("Device read failed for %s with error %ld", vxi->address, read_resp ? read_resp->error : 0); + if (read_resp) { + g_free(read_resp->data.data_val); + read_resp->data.data_val = NULL; + } return SR_ERR; } memcpy(buf, read_resp->data.data_val, read_resp->data.data_len); + g_free(read_resp->data.data_val); + read_resp->data.data_val = NULL; vxi->read_complete = read_resp->reason & (RRR_TERM | RRR_END); return read_resp->data.data_len; /* actual number of bytes received */ }