[gnome-control-center] tests: close opened directory



commit 2b14ccdf86812eeff06f4b12b7ebe52c057fdaa5
Author: RyuzakiKK <aasonykk gmail com>
Date:   Thu Aug 23 14:33:20 2018 +0200

    tests: close opened directory
    
    The directory opened with `g_dir_open` is never closed, so LeakSanitizer
    complains about a memory leaks.
    
    ```
    Direct leak of 8 byte(s) in 1 object(s) allocated from:
    /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86
        #1 0x7f2012908ac9 in g_malloc (/usr/lib/libglib-2.0.so.0+0x51ac9)
        #2 0x7f2012922aac in g_memdup (/usr/lib/libglib-2.0.so.0+0x6baac)
        #3 0x7f20128ed2d5  (/usr/lib/libglib-2.0.so.0+0x362d5)
        #4 0x7f20128ed338 in g_dir_open (/usr/lib/libglib-2.0.so.0+0x36338)
    ../tests/datetime/test-endianess.c:29
        #6 0x7f201292a76a  (/usr/lib/libglib-2.0.so.0+0x7376a)
        #7 0x7f201292a69a  (/usr/lib/libglib-2.0.so.0+0x7369a)
    (/usr/lib/libglib-2.0.so.0+0x73951)
        #9 0x7f201292a972 in g_test_run (/usr/lib/libglib-2.0.so.0+0x73972)
        #10 0x560ad630cbff in main ../tests/datetime/test-endianess.c:66
    ```

 tests/datetime/test-endianess.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/tests/datetime/test-endianess.c b/tests/datetime/test-endianess.c
index 06b26131b..9cb92007a 100644
--- a/tests/datetime/test-endianess.c
+++ b/tests/datetime/test-endianess.c
@@ -23,7 +23,7 @@ print_endianess (const char *lang)
 static void
 test_endianess (void)
 {
-       GDir *dir;
+       g_autoptr(GDir) dir = NULL;
        const char *name;
 
        dir = g_dir_open ("/usr/share/i18n/locales/", 0, NULL);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]