libs/posix: Fix NULL pointer in uselocale

uselocale now attempts to create a backend and a databrige.

If the attempt fails due to a missing libroot-addon-icu, uselocale
does nothing (to support applications calling uselocale during
startup to enforce the C locale).

Else, uselocale will fail with ENOMEM.

LocaleBackend::CreateBackend() has been modified to return a status_t
that indicates whether NULL is returned due to out of memory (B_NO_MEMORY)
or due to being unable to load the ICU addon (B_MISSING_LIBRARY).

Change-Id: I0f62ebde5890364c64e6694ec58d38de43ec6841
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5505
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
Trung Nguyen
2022-08-03 00:16:08 +00:00
committed by waddlesplash
parent b9643e557d
commit d02c0bade7
3 changed files with 41 additions and 16 deletions
@@ -187,7 +187,7 @@ public:
virtual void Initialize(LocaleDataBridge* dataBridge) = 0;
static status_t LoadBackend();
static LocaleBackend* CreateBackend();
static status_t CreateBackend(LocaleBackend*& backendOut);
static void DestroyBackend(LocaleBackend* instance);
};