From 809980e5e265ef12343d798470e2d88bbfa7a1f5 Mon Sep 17 00:00:00 2001 From: Kolja Waschk Date: Thu, 29 May 2008 07:04:29 +0000 Subject: [PATCH] Update for the fix of malloc/free issue by H.Sweeten git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1262 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- jtag/ChangeLog | 6 +++--- jtag/src/tap/cable/usbblaster.c | 22 ++++++++++------------ 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/jtag/ChangeLog b/jtag/ChangeLog index d8e39a39..f11ee3f2 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -2,9 +2,9 @@ * src/cmd/cable.c, src/tap/cable/wiggler.c, src/tap/cable/generic_usbconn.c, src/tap/cable/vision_ep9307.c, - src/tap/cable/jim.c, src/tap/cable/ft2232.c, - src/tap/cable/generic_parport.c: Cable connect/disconnect cleanup, - fix malloc/free issues (Hartley Sweeten) + src/tap/cable/jim.c, src/tap/cable/ft2232.c, + src/tap/cable/usbblaster.c, src/tap/cable/generic_parport.c: Cable + connect/disconnect cleanup, fix malloc/free issues (Hartley Sweeten) 2008-05-27 Arnim Laeuger diff --git a/jtag/src/tap/cable/usbblaster.c b/jtag/src/tap/cable/usbblaster.c index 4c98343d..03006acf 100644 --- a/jtag/src/tap/cable/usbblaster.c +++ b/jtag/src/tap/cable/usbblaster.c @@ -67,26 +67,24 @@ usbblaster_connect( char *params[], cable_t *cable ) params_t *cable_params; int result; + /* perform generic_usbconn_connect */ + if ( ( result = generic_usbconn_connect( params, cable ) ) != 0 ) + return result; + cable_params = (params_t *)malloc( sizeof(params_t) ); if (!cable_params) { - free( cable ); + printf( _("%s(%d) malloc failed!\n"), __FILE__, __LINE__); return 4; } - /* perform generic_usbconn_connect */ - result = generic_usbconn_connect( params, cable ); + cx_cmd_init( &(cable_params->cmd_root) ); - if (result == 0) - { - cx_cmd_init( &(cable_params->cmd_root) ); + /* exchange generic cable parameters with our private parameter set */ + free( cable->params ); + cable->params = cable_params; - /* exchange generic cable parameters with our private parameter set */ - free( cable->params ); - cable->params = cable_params; - } - - return result; + return 0; } static int