2003-01-06 Marcel Telka <marcel@telka.sk>

* src/discovery.c (discovery): Fixed memory leaks, added out of memory test,
		added test for invalid IR length.


git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@293 b68d4a1b-bc3d-0410-92ed-d4ac073336b7
master
Marcel Telka 22 years ago
parent d9f7ffadf5
commit d278440273

@ -1,3 +1,8 @@
2003-01-06 Marcel Telka <marcel@telka.sk>
* src/discovery.c (discovery): Fixed memory leaks, added out of memory test,
added test for invalid IR length.
2003-01-05 Marcel Telka <marcel@telka.sk>
* include/register.h (register_inc, register_dec, register_shift_right,

@ -149,13 +149,17 @@ discovery( const char *filename )
if (!register_compare( ones, id )) {
printf( "bad JTAG connection (TDO is 1)\n" );
fprintf( f, "bad JTAG connection (TDO is 1)\n" );
return; /* FIXME: memory leak */
break;
}
printf( "ID[%d]: %s\n", i, register_get_string( id ) );
fprintf( f, "ID[%d]: %s\n", i, register_get_string( id ) );
}
register_free( id );
register_free( zeros );
register_free( ones );
if (i == MAX_CHAIN_LENGTH) {
printf( "Warning: Maximum internal JTAG chain length exceeded!\n" );
fprintf( f, "Warning: Maximum internal JTAG chain length exceeded!\n" );
@ -176,9 +180,23 @@ discovery( const char *filename )
printf( "IR length is %d\n\n", irlen );
fprintf( f, "IR length is %d\n\n", irlen );
if (irlen < 1) {
printf( "Error: Invalid IR length!\n" );
fclose( f );
return;
}
ir = register_fill( register_alloc( irlen ), 0 );
irz = register_duplicate( ir );
/* TODO: test for out of memory */
if (!ir || !irz) {
register_free( ir );
register_free( irz );
fclose( f );
printf( "Error: Out of memory!\n" );
return;
}
for (;;) {
int rs;

Loading…
Cancel
Save