From: Arran Cudbard-Bell Date: Fri, 13 Mar 2020 00:21:58 +0000 (-0400) Subject: global: Explicit free functions for memory that's also freed by thread-local destruct... X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3ca0c45593602b97048191a2ecbfb126bb42c9e;p=thirdparty%2Ffreeradius-server.git global: Explicit free functions for memory that's also freed by thread-local destructors should be removed Because they're not needed, because we fixed the underlying issue, and now they cause a double free! --- diff --git a/src/bin/unit_test_attribute.c b/src/bin/unit_test_attribute.c index b9e89f568f8..76cac1d4c25 100644 --- a/src/bin/unit_test_attribute.c +++ b/src/bin/unit_test_attribute.c @@ -2541,12 +2541,6 @@ cleanup: ret = EXIT_FAILURE; } - /* - * Must be last, we still need the errors - * from fr_touch. - */ - fr_strerror_free(); - /* * Explicitly free the autofree context * to make errors less confusing. diff --git a/src/bin/unit_test_map.c b/src/bin/unit_test_map.c index 844d208f9f9..e9c15eacdea 100644 --- a/src/bin/unit_test_map.c +++ b/src/bin/unit_test_map.c @@ -251,8 +251,6 @@ cleanup: fr_dict_free(&dict); - fr_strerror_free(); - if (receipt_file && (ret == EXIT_SUCCESS) && (fr_touch(NULL, receipt_file, 0644, true, 0755) <= 0)) { fr_perror("unit_test_map"); ret = EXIT_FAILURE; diff --git a/src/bin/unit_test_module.c b/src/bin/unit_test_module.c index 96fc69a526d..b6b561d6c51 100644 --- a/src/bin/unit_test_module.c +++ b/src/bin/unit_test_module.c @@ -1171,12 +1171,6 @@ cleanup: ret = EXIT_FAILURE; } - /* - * Explicitly cleanup the buffer used for storing syserror messages - * This cuts down on address sanitiser output on error. - */ - fr_syserror_free(); - return ret; } diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 21e2a39b97a..1f12955f3f8 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -322,17 +322,6 @@ void fr_perror(char const *fmt, ...) talloc_free(prefix); } -/** Explicitly free the memory used by fr_strerror - * - * Note that this function is ONLY called in single-threaded mode, - * and then ONLY when the main thread does not call pthread_exit(NULL) - */ -void fr_strerror_free(void) -{ - TALLOC_FREE(fr_strerror_buffer); - logging_stop = true; -} - #ifdef TESTING_STRERROR /* * cc strerror.c -g3 -Wall -DTESTING_STRERROR -L/usr/local/lib -L ../../../build/lib/local/.libs/ -lfreeradius-util -I/usr/local/include -I../../ -I../ -include ../include/build.h -l talloc -o test_strerror && ./test_strerror diff --git a/src/lib/util/strerror.h b/src/lib/util/strerror.h index 36e8db9a7be..a658f17abe4 100644 --- a/src/lib/util/strerror.h +++ b/src/lib/util/strerror.h @@ -41,7 +41,6 @@ char const *fr_strerror_peek(void); char const *fr_strerror_pop(void); void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2)); -void fr_strerror_free(void); #ifdef __cplusplus } diff --git a/src/lib/util/syserror.c b/src/lib/util/syserror.c index 7baaebeefd7..0ca3c217097 100644 --- a/src/lib/util/syserror.c +++ b/src/lib/util/syserror.c @@ -259,12 +259,3 @@ char const *fr_syserror(int num) } #endif } - -/** Explicitly cleanup the thread specific buffer used - * - */ -void fr_syserror_free(void) -{ - _fr_logging_free(NULL); -} - diff --git a/src/lib/util/syserror.h b/src/lib/util/syserror.h index 5239ffc72a3..80147189c8d 100644 --- a/src/lib/util/syserror.h +++ b/src/lib/util/syserror.h @@ -36,7 +36,6 @@ extern "C" { #include char const *fr_syserror(int num); -void fr_syserror_free(void); #ifdef __cplusplus }