diff options
author | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-12-08 10:21:17 -0500 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@gotplt.org> | 2022-12-08 10:21:18 -0500 |
commit | 955093369ed41e7ad7d9e4fadc2948375a6cb103 (patch) | |
tree | 4d5696854b13a41ba9089da90dd38a9e8581f563 | |
parent | d9f9d5d30feb33c359955d7030cc6be50ef6dc0a (diff) | |
download | gcc-955093369ed41e7ad7d9e4fadc2948375a6cb103.zip gcc-955093369ed41e7ad7d9e4fadc2948375a6cb103.tar.gz gcc-955093369ed41e7ad7d9e4fadc2948375a6cb103.tar.bz2 |
testsuite: Fix leaks in tree-dynamic-object-size-0.c
In commit e5cfb9cac1d7aba9a8ea73bfe7922cfaff9d61f3 I introduced tests
for strdup and strndup with leaks. Fix those leaks.
gcc/testsuite/ChangeLog:
* gcc.dg/builtin-dynamic-object-size-0.c (test_strdup,
test_strndup, test_strdup_min, test_strndup_min): Free RES
before returning from function.
Signed-off-by: Siddhesh Poyarekar <siddhesh@gotplt.org>
-rw-r--r-- | gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c index 4f1606a..f9047a0 100644 --- a/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c +++ b/gcc/testsuite/gcc.dg/builtin-dynamic-object-size-0.c @@ -486,7 +486,10 @@ __attribute__ ((noinline)) test_strdup (const char *in) { char *res = __builtin_strdup (in); - return __builtin_dynamic_object_size (res, 0); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; } size_t @@ -494,7 +497,10 @@ __attribute__ ((noinline)) test_strndup (const char *in, size_t bound) { char *res = __builtin_strndup (in, bound); - return __builtin_dynamic_object_size (res, 0); + size_t sz = __builtin_dynamic_object_size (res, 0); + + __builtin_free (res); + return sz; } size_t @@ -502,7 +508,10 @@ __attribute__ ((noinline)) test_strdup_min (const char *in) { char *res = __builtin_strdup (in); - return __builtin_dynamic_object_size (res, 2); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; } size_t @@ -510,7 +519,10 @@ __attribute__ ((noinline)) test_strndup_min (const char *in, size_t bound) { char *res = __builtin_strndup (in, bound); - return __builtin_dynamic_object_size (res, 2); + size_t sz = __builtin_dynamic_object_size (res, 2); + + __builtin_free (res); + return sz; } /* Other tests. */ |