X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=blobdiff_plain;f=src%2Fscpi%2Fscpi_vxi.c;h=9b38efdab1c83581146b3fe5a0344019bce49d44;hp=2b8e50dee5688ce3a7383e29949ee959086d5dc2;hb=ed787682255cdecbb3ba8cefc87c20182b97ce7b;hpb=7414fb55cb1ff4472176318d0e1146abfd2b7163 diff --git a/src/scpi/scpi_vxi.c b/src/scpi/scpi_vxi.c index 2b8e50de..9b38efda 100644 --- a/src/scpi/scpi_vxi.c +++ b/src/scpi/scpi_vxi.c @@ -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 */ }