From ab25ad54e84d3e4680e1a7991c8aea6ad6d82b06 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Thu, 24 Jan 2013 12:09:40 -0800 Subject: [PATCH] Fix potential for crash if tmxr_set_get_modem_bits is called without the multiplexer device being attached --- sim_defs.h | 1 + sim_tmxr.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sim_defs.h b/sim_defs.h index d970d9af..bb8ab4e4 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -117,6 +117,7 @@ #include #undef PACKED /* avoid macro name collision */ #undef ERROR /* avoid macro name collision */ +#undef MEM_MAPPED /* avoid macro name collision */ #endif #ifndef TRUE diff --git a/sim_tmxr.c b/sim_tmxr.c index 1976550f..4eee20f8 100644 --- a/sim_tmxr.c +++ b/sim_tmxr.c @@ -1062,12 +1062,12 @@ if ((bits_to_set & ~(TMXR_MDM_OUTGOING)) || /* Assure only settable bits (bits_to_set & bits_to_clear)) /* and can't set and clear the same bits */ return SCPE_ARG; if (incoming_bits) { - if (lp->sock) + if ((lp->sock) || (lp->serport)) *incoming_bits = TMXR_MDM_DCD | TMXR_MDM_CTS | TMXR_MDM_DSR; else - *incoming_bits = lp->mp->master ? (TMXR_MDM_CTS | TMXR_MDM_DSR) : 0; + *incoming_bits = (lp->mp && lp->mp->master) ? (TMXR_MDM_CTS | TMXR_MDM_DSR) : 0; } -if (lp->mp->modem_control) { /* This API ONLY works on modem_control enabled multiplexers */ +if (lp->mp && lp->mp->modem_control) { /* This API ONLY works on modem_control enabled multiplexers */ if (lp->serport) return sim_control_serial (lp->serport, bits_to_set, bits_to_clear, incoming_bits); if (lp->sock) {