Fix a crash in a unit test if nb_NO.UTF-8 is not available.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 14 Dec 2015 01:10:00 +0000 (02:10 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 14 Dec 2015 01:10:03 +0000 (02:10 +0100)
effect_chain_test.cpp

index 596570c..32beb41 100644 (file)
@@ -1248,7 +1248,12 @@ TEST(EffectChainTest, StringStreamLocalesWork) {
        // the test will always succeed. Note that the OpenGL driver might call
        // setlocale() behind-the-scenes, and that might corrupt the returned
        // pointer, so we need to take our own copy of it here.
-       char *saved_locale = strdup(setlocale(LC_ALL, "nb_NO.UTF_8"));
+       char *saved_locale = setlocale(LC_ALL, "nb_NO.UTF_8");
+       if (saved_locale == NULL) {
+               // The locale wasn't available.
+               return;
+       }
+       saved_locale = strdup(saved_locale);
        float data[] = {
                0.0f, 0.0f, 0.0f, 0.0f,
        };