summaryrefslogtreecommitdiff
path: root/vxi11_server.c
diff options
context:
space:
mode:
authordaniel <danieruru@gmail.com>2013-01-25 23:09:40 +0900
committerdaniel <danieruru@gmail.com>2013-01-25 23:09:40 +0900
commite3d04285a9460a8ab13e9725fc2febf1be63a4d9 (patch)
tree50878fe2c72bf8a3164357810d1cce576b9075d7 /vxi11_server.c
parent008d5f4b9f3cad2d5fe350fa525b8a2135b97785 (diff)
docmd and better termination fix
Diffstat (limited to 'vxi11_server.c')
-rw-r--r--vxi11_server.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/vxi11_server.c b/vxi11_server.c
index cb7f600..ae8317f 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -204,18 +204,16 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
result.error = ERR_IOTIMEOUT;
else {
touchlink(argp->lid);
- argp->data.data_val = realloc(argp->data.data_val, argp->data.data_len + 1); // realloc to get an extra byte
- argp->data.data_val[argp->data.data_len] = '\0'; //
+ gchar* str = g_strndup(argp->data.data_val, argp->data.data_len);
#ifdef DEBUG
int n;
- char *str = argp->data.data_val;
for (n = 0; str[n] != '\0'; n++)
printf("%02x ", (unsigned char) str[n]);
printf("\n");
- printf("got <<%s>> (reported length %d)on link %d.\n", argp->data.data_val, (int) argp->data.data_len,
- (int) argp->lid);
+ printf("got <<%s>> (reported length %d)on link %d.\n", str, (int) argp->data.data_len, (int) argp->lid);
#endif
- Parser_main(argp->data.data_val, 0, GPIB_and_VXI_start_query_response, NULL);
+ Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL);
+ g_free(str);
result.size = argp->data.data_len;
}