Skip to content

Commit 1903cfe

Browse files
committed
openssl: don't fail when we can't customize allocators
During valgrind runs, we try to swap out the OpenSSL allocators for our own. This allows us to avoid some unnecessary warnings about usage. Unfortunately, many builds of OpenSSL do not allow you to swap allocators; for example FIPS builds and the builds running in CentOS. Try to swap the allocators, but do not fail when they cannot be customized.
1 parent 3f02b5b commit 1903cfe

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/streams/openssl.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,13 +251,18 @@ int git_openssl_stream_global_init(void)
251251
#endif
252252

253253
#ifdef VALGRIND
254-
/* Swap in our own allocator functions that initialize allocated memory */
255-
if (!allocators_initialized &&
254+
/*
255+
* Swap in our own allocator functions that initialize
256+
* allocated memory to avoid spurious valgrind warnings.
257+
* Don't error on failure; many builds of OpenSSL do not
258+
* allow you to set these functions.
259+
*/
260+
if (!allocators_initialized) {
256261
CRYPTO_set_mem_functions(git_openssl_malloc,
257262
git_openssl_realloc,
258-
git_openssl_free) != 1)
259-
goto error;
260-
allocators_initialized = true;
263+
git_openssl_free);
264+
allocators_initialized = true;
265+
}
261266
#endif
262267

263268
OPENSSL_init_ssl(0, NULL);

0 commit comments

Comments
 (0)