From 1ccbff1f2b88e0c51da2af46755595e4226c23bc Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 31 Jan 2013 02:51:04 +0900 Subject: Don't dereference null pointers, don't go passing them to the parser (stops lots of glib asserts). --- vxi11_server.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'vxi11_server.c') diff --git a/vxi11_server.c b/vxi11_server.c index 2d1a455..f367694 100644 --- a/vxi11_server.c +++ b/vxi11_server.c @@ -254,16 +254,20 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) { else { touchlink(argp->lid); links[argp->lid]->aborted = false; - gchar* str = g_strndup(argp->data.data_val, argp->data.data_len); -#ifdef DEBUG - int n; - 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", str, (int) argp->data.data_len, (int) argp->lid); -#endif - Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL ); - g_free(str); + gchar* str = NULL; + if (argp->data.data_val != NULL ) + str = g_strndup(argp->data.data_val, argp->data.data_len); + if (str != NULL ) { +#ifdef DEBUG + int n; + 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", str, (int) argp->data.data_len, (int) argp->lid); +#endif + Parser_main(str, 0, GPIB_and_VXI_start_query_response, NULL ); + g_free(str); + } result.size = argp->data.data_len; } @@ -277,7 +281,7 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) { printf("device_read_1_svc()\n"); #endif - // this free's the data from the last call +// this free's the data from the last call if (result.data.data_val != NULL ) g_free(result.data.data_val); @@ -549,8 +553,8 @@ create_intr_chan_1_svc(Device_RemoteFunc *argp, struct svc_req *rqstp) { printf("Client %s is asking for an interrupt connection on port %u\n", clientaddressstring, (unsigned int) port); #endif - // if a client had an interrupt channel and died without closing it - // we need to clean it up to avoid a deadlock +// if a client had an interrupt channel and died without closing it +// we need to clean it up to avoid a deadlock static struct rpc_err err; if (intclient != NULL ) { vxi11_fireinterrupt(); -- cgit