summaryrefslogtreecommitdiff
path: root/vxi11_server.c
diff options
context:
space:
mode:
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;
}