Merge branch 'memcheck-fix' into development

This commit is contained in:
Paul Bakker 2016-05-12 16:45:35 +01:00
commit cf1c6da664
2 changed files with 28 additions and 8 deletions

View File

@ -26,6 +26,7 @@ Bugfix
* Fix issue that caused a crash if invalid curves were passed to * Fix issue that caused a crash if invalid curves were passed to
mbedtls_ssl_conf_curves. #373 mbedtls_ssl_conf_curves. #373
* Fix issue in ssl_fork_server which was preventing it from functioning. #429 * Fix issue in ssl_fork_server which was preventing it from functioning. #429
* Fix memory leaks in test framework
Changes Changes
* On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5, * On ARM platforms, when compiling with -O0 with GCC, Clang or armcc5,

View File

@ -321,6 +321,9 @@ int main(int argc, const char *argv[])
testfile_index < testfile_count; testfile_index < testfile_count;
testfile_index++ ) testfile_index++ )
{ {
int unmet_dep_count = 0;
char *unmet_dependencies[20];
test_filename = test_files[ testfile_index ]; test_filename = test_files[ testfile_index ];
file = fopen( test_filename, "r" ); file = fopen( test_filename, "r" );
@ -333,8 +336,12 @@ int main(int argc, const char *argv[])
while( !feof( file ) ) while( !feof( file ) )
{ {
int unmet_dep_count = 0; if( unmet_dep_count > 0 )
char *unmet_dependencies[20]; {
mbedtls_printf("FATAL: Dep count larger than zero at start of loop\n");
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
}
unmet_dep_count = 0;
if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 ) if( ( ret = get_line( file, buf, sizeof(buf) ) ) != 0 )
break; break;
@ -357,8 +364,15 @@ int main(int argc, const char *argv[])
{ {
if( dep_check( params[i] ) != DEPENDENCY_SUPPORTED ) if( dep_check( params[i] ) != DEPENDENCY_SUPPORTED )
{ {
unmet_dependencies[ i-1 ] = strdup(params[i]); if( 0 == option_verbose )
if( unmet_dependencies[ i-1 ] == NULL ) {
/* Only one count is needed if not verbose */
unmet_dep_count++;
break;
}
unmet_dependencies[ unmet_dep_count ] = strdup(params[i]);
if( unmet_dependencies[ unmet_dep_count ] == NULL )
{ {
mbedtls_printf("FATAL: Out of memory\n"); mbedtls_printf("FATAL: Out of memory\n");
mbedtls_exit( MBEDTLS_EXIT_FAILURE ); mbedtls_exit( MBEDTLS_EXIT_FAILURE );
@ -392,16 +406,17 @@ int main(int argc, const char *argv[])
if( 1 == option_verbose && unmet_dep_count > 0 ) if( 1 == option_verbose && unmet_dep_count > 0 )
{ {
mbedtls_fprintf( stdout, " Unmet dependencies: " ); mbedtls_fprintf( stdout, " Unmet dependencies: " );
while( unmet_dep_count > 0) for( i = 0; i < unmet_dep_count; i++ )
{ {
mbedtls_fprintf(stdout, "%s ", mbedtls_fprintf(stdout, "%s ",
unmet_dependencies[unmet_dep_count - 1]); unmet_dependencies[i]);
free(unmet_dependencies[unmet_dep_count - 1]); free(unmet_dependencies[i]);
unmet_dep_count--;
} }
mbedtls_fprintf( stdout, "\n" ); mbedtls_fprintf( stdout, "\n" );
} }
fflush( stdout ); fflush( stdout );
unmet_dep_count = 0;
} }
else if( ret == DISPATCH_TEST_SUCCESS && test_errors == 0 ) else if( ret == DISPATCH_TEST_SUCCESS && test_errors == 0 )
{ {
@ -427,6 +442,10 @@ int main(int argc, const char *argv[])
} }
} }
fclose(file); fclose(file);
/* In case we encounter early end of file */
for( i = 0; i < unmet_dep_count; i++ )
free( unmet_dependencies[i] );
} }
mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n"); mbedtls_fprintf( stdout, "\n----------------------------------------------------------------------------\n\n");