[network-manager-vpnc] test: use setlocale(NULL) instead of g_get_charset()



commit 22a59c11c3b7cd559cfedb6f3d55214e0368163e
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Mon Aug 31 22:35:06 2015 +0200

    test: use setlocale(NULL) instead of g_get_charset()
    
    Apparently, whatever g_get_charset() returns is valid only until next
    call to it. Makes Valgrind unhappy. Mixing g_get_charset() and
    setlocale() is probably a bad idea anyway...
    
    ==28765== Invalid read of size 2
    ==28765==    at 0x4C2DA40: __GI_memcpy (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28765==    by 0x90B7EF0: _nl_find_locale (findlocale.c:173)
    ==28765==    by 0x90B796B: setlocale (setlocale.c:340)
    ==28765==    by 0x4020CF: test_non_utf8_import (test-import-export.c:615)
    ==28765==    by 0x4020CF: main (test-import-export.c:772)
    ==28765==  Address 0x11af8568 is 8 bytes inside a block of size 15 free'd
    ==28765==    at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==28765==    by 0x8B9579E: g_free (gmem.c:192)
    ==28765==    by 0x8B6B7C0: g_get_charset (gcharset.c:199)
    ==28765==    by 0x8B72DC2: g_locale_to_utf8 (gconvert.c:904)
    ==28765==    by 0x8E897B9: get_string_as_utf8 (nm-vpnc-helper.c:107)
    ==28765==    by 0x8E899B8: key_file_get_string_helper (nm-vpnc-helper.c:130)
    ==28765==    by 0x8E845FB: import (nm-vpnc.c:1346)
    ==28765==    by 0x402FD2: get_basic_connection.isra.0 (test-import-export.c:123)
    ==28765==    by 0x4020BD: test_non_utf8_import (test-import-export.c:614)
    ==28765==    by 0x4020BD: main (test-import-export.c:772)

 properties/tests/test-import-export.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 350d424..7007f5c 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -606,10 +606,10 @@ test_non_utf8_import (NMVpnEditorPlugin *plugin, const char *dir)
        NMSettingConnection *s_con;
        NMSettingVpn *s_vpn;
        const char *expected_id = "Att äta en ko";
-       const char *charset = NULL;
+       const char *charset;
 
        /* Change charset to ISO-8859-15 to match iso885915.pcf */
-       g_get_charset (&charset);
+       charset = setlocale (LC_ALL, NULL);
        setlocale (LC_ALL, "de_DE euro");
        connection = get_basic_connection ("non-utf8-import", plugin, dir, "iso885915.pcf");
        setlocale (LC_ALL, charset);


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