]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Try and track down leak
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 20:06:38 +0000 (16:06 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Wed, 5 Jul 2017 20:06:49 +0000 (16:06 -0400)
src/include/fr_log.h
src/lib/util/strerror.c
src/main/unit_test_attribute.c

index cce2510576a7fa766bf3fa213615eab87c20ae92..60904add549bb99a63f4eab9d046663b4b322b08 100644 (file)
@@ -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);
index 10d2c68a3349160594fe3a5bb24aa2e4db9660a0..911d154e4c3e553cd3fe8d9f27b60ac466c9da60 100644 (file)
@@ -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
 /*
index 54b873bf07d22eec58c0394a0255836808ab9d0f..d4b27e79364b4c00cdde1041690da64774c6e1d5 100644 (file)
@@ -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;