diff options
author | daniel <danieruru@gmail.com> | 2013-01-31 02:51:04 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-31 02:51:04 +0900 |
commit | 1ccbff1f2b88e0c51da2af46755595e4226c23bc (patch) | |
tree | 0d7d2a7d324b8dacfec76d10234d642178bbcb49 /vxi11_server.c | |
parent | d4ced2f9e43fde33fe94355256b1c4c7525d670d (diff) |
Don't dereference null pointers, don't go passing them to the parser (stops lots of glib asserts).
Diffstat (limited to 'vxi11_server.c')
-rw-r--r-- | vxi11_server.c | 30 |
1 files changed, 17 insertions, 13 deletions
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(); |