From 4cf76ac1b1565a8710b2906dbd2d03a2b53cedfe Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Mon, 14 Dec 2015 02:10:00 +0100 Subject: [PATCH] Fix a crash in a unit test if nb_NO.UTF-8 is not available. --- effect_chain_test.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/effect_chain_test.cpp b/effect_chain_test.cpp index 596570c..32beb41 100644 --- a/effect_chain_test.cpp +++ b/effect_chain_test.cpp @@ -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, }; -- 2.39.2