From: Steinar H. Gunderson Date: Mon, 14 Dec 2015 01:10:00 +0000 (+0100) Subject: Fix a crash in a unit test if nb_NO.UTF-8 is not available. X-Git-Tag: 1.3.0~11 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=4cf76ac1b1565a8710b2906dbd2d03a2b53cedfe Fix a crash in a unit test if nb_NO.UTF-8 is not available. --- 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, };