From 505273e123bc324689a7d3da41aa1d68401f1c71 Mon Sep 17 00:00:00 2001 From: Michael Black Date: Tue, 16 Jul 2019 11:05:13 -0500 Subject: [PATCH] Fix segfault in flrig.c --- dummy/flrig.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dummy/flrig.c b/dummy/flrig.c index 6ecb50929..e75a70182 100644 --- a/dummy/flrig.c +++ b/dummy/flrig.c @@ -943,8 +943,10 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) // Set the mode char *ttmode = strdup(modeMapGetFLRig(mode)); - if (ttmode[0]=='|') ttmode = &ttmode[1]; // remove first pipe symbol - char *p=strchr(ttmode,'|'); + rig_debug(RIG_DEBUG_TRACE,"%s: got ttmode = %s\n",__FUNCTION__,ttmode==NULL?"NULL":ttmode); + char *pttmode = ttmode; + if (ttmode[0]=='|') pttmode = &ttmode[1]; // remove first pipe symbol + char *p=strchr(pttmode,'|'); if (p) *p=0; // remove any other pipe char cmd_buf[MAXCMDLEN]; @@ -963,11 +965,13 @@ static int flrig_set_mode(RIG *rig, vfo_t vfo, rmode_t mode, pbwidth_t width) pxml = xml_build(cmd, cmd_buf, xml, sizeof(xml)); } + rig_debug(RIG_DEBUG_TRACE,"%s: write_transaction\n",__FUNCTION__); retval = write_transaction(rig, pxml, strlen(pxml)); if (retval < 0) { return retval; } + rig_debug(RIG_DEBUG_TRACE,"%s: read_transaction\n",__FUNCTION__); // Get the response read_transaction(rig, xml, sizeof(xml)); rig_debug(RIG_DEBUG_TRACE, "%s: response=%s\n", __FUNCTION__,xml);