On Tue, Feb 17, 2015 at 10:07 PM, Paul Eggert <egg...@cs.ucla.edu> wrote: > Kevin Cernekee wrote: >>>> >>>> test-localename is calling strdup() on a NULL pointer returned by >>>> >>gl_locale_name_thread(), and crashing. From reading >>>> >>gl_locale_name_thread() it seems like NULL is a valid result. Maybe >>>> >> we >>>> >>need to change the test case to "return 77" on systems that are >>>> >> unaware >>>> >>of locales? >>> >>> > >>> > >>> >Yes, that sounds right. Can you propose a patch along those lines? >> >> OK. Should I just check for NULL, or is there a better test that >> would indicate that the locale support is completely absent? > > > I haven't read that part of the code, but it sounds like a NULL test would > be good enough.
What I found is that for Android API levels < 21, gnulib correctly detects that locale support is absent and the test becomes a no-op. For API level >= 21, the only missing piece was obtaining an ASCII name for the current thread's locale ("C" or "C.UTF-8"), which my patch accomplished by checking MB_CUR_MAX. So now we don't get a NULL pointer, and the test passes on Android. We might still want to add a NULL check in the test program, rather than just segfaulting.