X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fscpi%2Fscpi.c;h=9f5dba43ae493a5b4558b1970186c07ddd69b417;hb=055804e89ea0f6b4145040a0eeb2f4e6951692fe;hp=fc7e9939c0e72ae5dfe173b25147ead17ffe5143;hpb=66836720f73c12fb107aa28b79cc6420c721cc5d;p=libsigrok.git diff --git a/src/scpi/scpi.c b/src/scpi/scpi.c index fc7e9939..9f5dba43 100644 --- a/src/scpi/scpi.c +++ b/src/scpi/scpi.c @@ -296,8 +296,10 @@ SR_PRIV int sr_scpi_send_variadic(struct sr_scpi_dev_inst *scpi, va_end(args_copy); /* Allocate buffer and write out command. */ - buf = g_malloc(len + 1); + buf = g_malloc0(len + 2); vsprintf(buf, format, args); + if (buf[len - 1] != '\n') + buf[len] = '\n'; /* Send command. */ ret = scpi->send(scpi->priv, buf);