From: Arran Cudbard-Bell Date: Wed, 5 Jul 2017 20:06:38 +0000 (-0400) Subject: Try and track down leak X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cf1f13dc2da08df59691bfd7bf2e850d794665ff;p=thirdparty%2Ffreeradius-server.git Try and track down leak --- diff --git a/src/include/fr_log.h b/src/include/fr_log.h index cce2510576a..60904add549 100644 --- a/src/include/fr_log.h +++ b/src/include/fr_log.h @@ -45,6 +45,7 @@ char const *fr_strerror(void); char const *fr_strerror_pop(void); void fr_perror(char const *, ...) CC_HINT(format (printf, 1, 2)); +void fr_strerror_free(void); void fr_canonicalize_error(TALLOC_CTX *ctx, char **spaces, char **text, ssize_t slen, char const *msg); char const *fr_syserror(int num); diff --git a/src/lib/util/strerror.c b/src/lib/util/strerror.c index 10d2c68a334..911d154e4c3 100644 --- a/src/lib/util/strerror.c +++ b/src/lib/util/strerror.c @@ -284,6 +284,13 @@ void fr_perror(char const *fmt, ...) talloc_free(prefix); } +/** Explicitly free the memory used by fr_strerror + * + */ +void fr_strerror_free(void) +{ + talloc_free(fr_strerror_buffer); +} #ifdef TESTING_STRERROR /* diff --git a/src/main/unit_test_attribute.c b/src/main/unit_test_attribute.c index 54b873bf07d..d4b27e79364 100644 --- a/src/main/unit_test_attribute.c +++ b/src/main/unit_test_attribute.c @@ -1083,7 +1083,7 @@ int main(int argc, char *argv[]) return 1; } - if (fr_dict_from_file(NULL, &dict, dict_dir, FR_DICTIONARY_FILE, "radius") < 0) { + if (fr_dict_from_file(autofree, &dict, dict_dir, FR_DICTIONARY_FILE, "radius") < 0) { fr_perror("unit_test_attribute"); return 1; } @@ -1098,7 +1098,7 @@ int main(int argc, char *argv[]) return 1; } - my_secret = talloc_strdup(NULL, "testing123"); + my_secret = talloc_strdup(autofree, "testing123"); if (argc < 2) { process_file(dict, NULL, "-"); @@ -1113,6 +1113,7 @@ int main(int argc, char *argv[]) fr_log_talloc_report(NULL); } + fr_strerror_free(); talloc_free(autofree); return 0;