mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-01-26 12:35:20 +00:00
Fix stdio redirection memory leak in test suites
This commit is contained in:
parent
f6e3b9e8b2
commit
edf2a3fba7
@ -140,6 +140,11 @@ static int restore_output( FILE** out_stream, int old_fd )
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void close_output( FILE* stdout )
|
||||||
|
{
|
||||||
|
fclose( stdout );
|
||||||
|
}
|
||||||
#endif /* __unix__ || __APPLE__ __MACH__ */
|
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||||
|
|
||||||
static int unhexify( unsigned char *obuf, const char *ibuf )
|
static int unhexify( unsigned char *obuf, const char *ibuf )
|
||||||
|
@ -261,7 +261,7 @@ int main(int argc, const char *argv[])
|
|||||||
char buf[5000];
|
char buf[5000];
|
||||||
char *params[50];
|
char *params[50];
|
||||||
void *pointer;
|
void *pointer;
|
||||||
int stdout_fd = 0;
|
int stdout_fd = -1;
|
||||||
|
|
||||||
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
|
#if defined(MBEDTLS_MEMORY_BUFFER_ALLOC_C) && \
|
||||||
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
!defined(TEST_SUITE_MEMORY_BUFFER_ALLOC)
|
||||||
@ -499,6 +499,11 @@ int main(int argc, const char *argv[])
|
|||||||
mbedtls_memory_buffer_alloc_free();
|
mbedtls_memory_buffer_alloc_free();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
if( stdout_fd != -1 )
|
||||||
|
close_output( stdout );
|
||||||
|
#endif /* __unix__ || __APPLE__ __MACH__ */
|
||||||
|
|
||||||
return( total_errors != 0 );
|
return( total_errors != 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user