From fac9057f022e5752fdfbe238ea69219d945d884e Mon Sep 17 00:00:00 2001 From: Stefan Mahr Date: Tue, 12 Mar 2013 10:43:21 +0100 Subject: [PATCH] jtag: parport: avoid freeing read-only memory section If command parport_cable is not executed, parport_cable points to const char array in read-only memory as default. On exit free() will try to free this read-only memory. This patch uses strdup to allocate memory when defining default setting. Change-Id: I290e707ac6a37e9dc1b45c85ca51d8bd6aac6761 Signed-off-by: Stefan Mahr Reviewed-on: http://openocd.zylin.com/1223 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/jtag/drivers/parport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index 3c07afb2..793b28f3 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -268,8 +268,8 @@ static int parport_init(void) cur_cable = cables; - if ((parport_cable == NULL) || (parport_cable[0] == 0)) { - parport_cable = "wiggler"; + if (parport_cable == NULL) { + parport_cable = strdup("wiggler"); LOG_WARNING("No parport cable specified, using default 'wiggler'"); } -- 2.39.5